How to set URL to accept Mime types?

12 views
Skip to first unread message

drjava

unread,
Jun 1, 2012, 6:25:05 PM6/1/12
to scala-user
I'm working on an app that gets an XML resource form the web. Like
this.


val url = new URL("http://server.com");
val data = scala.io.Source.fromURL(url).mkString

It works on some servers I use but on one I get an HTTP 406 error.
I believe it is because the particular server labels the content as
MIME application/xml while the servers that do work label it as MIME
text/xml.

In JAVA you can set the accept type on a "Connection" like this.
connection.setRequestProperty("Accept", "text/html+xml,application/
xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

But in the Scala version I feed the method the URL and don't have a
connection to "set".

How can I specify that I will accept MIME text/xml ?
Reply all
Reply to author
Forward
0 new messages