I’m POSTing some data to an IIS server which replies with an simple id (here 1692945):
Cache-Control: private
Content-Type: text; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Tue, 23 Aug 2011 17:08:37 GMT
Content-Length: 7
1692945
The text content type seems to confuse Jsoup which throws an:
Exception in thread "main" java.io.IOException: Unhandled content type "null" on URL http://domain.com/svr_listing.aspx. Must be text/*, application/xml, or application/xhtml+xml
Is there a way to specify that the response must be trated as text/plain? Is this a jsoup bug?
Thanks,
Nicolas
jsoup checks the response type by default, to protect you from accidently trying to parse images and PDFs etc as HTML. Because it doesn’t recognise
textas a valid HTML content-type, it is throwing an exception.You can force jsoup to ignore the content-type and parse the response as HTML with the
Connection.ignoreContentType()method.E.g.