rlalfo / google-http-java-client

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

EOFException using NetHttpTransport on HEAD request with gzip encoding #169

Closed GoogleCodeExporter closed 9 years ago

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

1.12.0-beta

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

All

Describe the problem.

Make a HEAD request using NetHttpTransport to gzip-encoded content and it will 
result in an EOFException.

Here's the log output and stack trace in a sample I've written:

CONFIG: -------------- REQUEST  --------------
HEAD https://www.googleapis.com/calendar/v3/users/me/calendarList
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: Google-CalendarSample/1.0 Google-HTTP-Java-Client/1.12.0-beta (gzip)

Nov 26, 2012 3:31:50 PM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -X HEAD -H 'Accept-Encoding: gzip' -H 
'Authorization: <Not Logged>' -H 'User-Agent: Google-CalendarSample/1.0 
Google-HTTP-Java-Client/1.12.0-beta (gzip)' -- 
https://www.googleapis.com/calendar/v3/users/me/calendarList
Nov 26, 2012 3:31:52 PM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 200 OK
ETag: "NybCyMgjkLQM6Il-p8A5652MtaE/E86055QdXW578YkMcayX-pGgswY"
Content-Length: 1071
Expires: Fri, 01 Jan 1990 00:00:00 GMT
X-Google-Apiary-Auth-User: 866721763087
X-Google-GFE-Service-Trace: apiserving
X-XSS-Protection: 1; mode=block
Server: GSE
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Google-DOS-Service-Trace: apiserving
X-Google-GFE-Response-Code-Details-Trace: response_code_set_by_backend
Date: Mon, 26 Nov 2012 20:31:52 GMT
X-Google-GFE-Request-Trace: 
qekt19:443,/bns/yn/borg/yn/bns/apiserving/prod_api_frontend.server/4,qekt19:443
X-Google-Apiary-Auth-Expires: 1353962210000
X-Google-Apiary-Auth-Scopes: https://www.googleapis.com/auth/calendar
X-Google-ServerType: apiserving
Content-Encoding: gzip
X-Google-Backends: 
yhia77:9854,/bns/yn/borg/yn/bns/apiserving/prod_api_frontend.server/4,qekt19:443
X-Google-Service: apiserving
Content-Type: application/json; charset=UTF-8

java.io.EOFException
    at java.util.zip.GZIPInputStream.readUByte(GZIPInputStream.java:264)
    at java.util.zip.GZIPInputStream.readUShort(GZIPInputStream.java:254)
    at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:163)
    at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:78)
    at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:90)
    at com.google.api.client.http.HttpResponse.getContent(HttpResponse.java:370)
    at com.google.api.client.http.HttpResponse.ignore(HttpResponse.java:432)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUsingHead(AbstractGoogleClientRequest.java:383)
    at com.google.api.services.calendar.Calendar$CalendarList$List.executeUsingHead(Calendar.java:636)
    at com.google.api.services.samples.calendar.cmdline.CalendarSample.showCalendars(CalendarSample.java:116)
    at com.google.api.services.samples.calendar.cmdline.CalendarSample.main(CalendarSample.java:95)

How would you expect it to be fixed?

It should behave the same as for ApacheHttpTransport and not throw an 
EOFException and treat the content as empty.

Original issue reported on code.google.com by yan...@google.com on 26 Nov 2012 at 8:37

GoogleCodeExporter commented 9 years ago
https://codereview.appspot.com/6846109/

Original comment by yan...@google.com on 11 Dec 2012 at 1:24