rlalfo / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

Ability to parse a JSON HttpResult containing the <!DOCTYPE html PUBLIC> tag #266

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client (e.g. 1.15.0-rc)?

1.15.0-rc

Java environment (e.g. Java 6, Android 2.3, App Engine)?

"1.7.0_25"

Describe the problem.

Currently the api client cannot parse an HttpResponse containing the following 
tag (for instance):

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
"http://www.w3.org/TR/REC-html40/loose.dtd">

I am trying to get the response/data of this URL:

http://www.metlink.org.nz/timetables/bus/091/inbound/mapdatajson

Everything was working perfectly fine, but the website added the <DOCTYPE> tag 
in their website and my app has stopped working.

How would you expect it to be fixed?

Sanitize the response and remove the <DOCTYPE> html tag to make it work. You 
can sanitize it by stripping out the <DOCTYPE> tag in the ParseAs(Class) method.

Original issue reported on code.google.com by julio.he...@gmail.com on 27 Aug 2014 at 6:01

GoogleCodeExporter commented 9 years ago
I don't believe when returning a page like this, the content type will be 
"application/json". In this case, you'll need a html parser, which this library 
doesn't provide and we don't have a plan for it either.

Original comment by wonder...@google.com on 30 Dec 2014 at 10:57