suvallur / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

java.util.zip.ZipException: incorrect header check #327

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello, 

New to Rest-Assured and I really want to integrate it into a testing framework 
in java.  I seem to be getting an error which I can not figure out.  When I try 
to print the response body it is throwing the following error. Any ideas or 
help would be appreciate it. 

java.util.zip.ZipException: incorrect header check

Here is my code. Sorry I have to be vague on the exact URL.

RestAssured.baseURI = "https://mytesturl.com";
RestAssured.port = 443;
RestAssured.basePath = "/externalApps/public";
RestAssured.useRelaxedHTTPSValidation();

String path = "/mobile";

Response response = expect().statusCode(200).given()
.parameters("Oper_Name", "getConfigInfo", 
"Config_Ver", "1.0",
"Os_Ver", "5.0.1",
"Device_Type", "iPhone OS",
"App_Ver", "1.0", 
"uApp_Id", "MDNR")
.when().get(path); 

System.out.println(response.getStatusCode());
System.out.println(response.statusLine());
System.out.println(response.getHeaders().toString());
System.out.println(response.getBody().prettyPrint()); //error here

Here is my print out on eclipse:

200
HTTP/1.1 200 OK
Server=FWS/7.0
Date=Wed, 07 May 2014 23:16:49 GMT
P3p=CP="UNI DEM GOV FIN STA COM NAV PRE INT ONL CUR ADM DEV PSA PSD CUSi IVDi 
IVAi TELi CONi TAI OUR OTRi"
Cache-control=private
Set-cookie=MC=Afb5ir0bthOYcuIBVKs_esM^5DcSAlNqvuAKhIYMIAA_cgABqjMGBAAAAQAGBVNqvu
AAQ03; path=/; domain=.<mydomain>.com; expires=Thu, 07-May-2015 23:16:48 GMT
Fsreqid=REQ536abee00a84860c20003f720000aa33
Fscalleeid=https-<mytesturl>.com-8443
Fselapsedtime=171985
Content-type=text/xml;charset=ISO-8859-1; charset=iso-8859-1
Content-encoding=deflate
Content-length=1928
Content-language=en-us,en
Exception in thread "main" java.util.zip.ZipException: incorrect header check
    at java.util.zip.InflaterInputStream.read(Unknown Source)
    at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:138)
    at org.apache.http.conn.EofSensorInputStream$read.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
    at com.jayway.restassured.internal.RestAssuredResponseOptionsGroovyImpl.convertStreamToByteArray(RestAssuredResponseOptionsGroovyImpl.groovy:429)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:148)
    at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:99)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:53)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:157)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:165)
    at com.jayway.restassured.internal.RestAssuredResponseOptionsGroovyImpl.charsetToString(RestAssuredResponseOptionsGroovyImpl.groovy:481)
    at com.jayway.restassured.internal.RestAssuredResponseOptionsGroovyImpl$charsetToString$3.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
    at com.jayway.restassured.internal.RestAssuredResponseOptionsGroovyImpl.asString(RestAssuredResponseOptionsGroovyImpl.groovy:169)
    at com.jayway.restassured.internal.RestAssuredResponseOptionsGroovyImpl.asString(RestAssuredResponseOptionsGroovyImpl.groovy:165)
    at com.jayway.restassured.internal.RestAssuredResponseOptionsImpl.asString(RestAssuredResponseOptionsImpl.java:193)
    at com.jayway.restassured.response.ResponseBodyData$asString.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at com.jayway.restassured.internal.support.Prettifier.getPrettifiedBodyIfPossible(Prettifier.groovy:43)
    at com.jayway.restassured.internal.support.Prettifier$getPrettifiedBodyIfPossible.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at com.jayway.restassured.internal.RestAssuredResponseOptionsGroovyImpl.prettyPrint(RestAssuredResponseOptionsGroovyImpl.groovy:150)
    at com.jayway.restassured.internal.RestAssuredResponseOptionsImpl.prettyPrint(RestAssuredResponseOptionsImpl.java:213)
    at 

Original issue reported on code.google.com by jtorres...@gmail.com on 7 May 2014 at 11:34

GoogleCodeExporter commented 9 years ago
Is the service you are trying to test available somewhere so that I can try it 
out?

Original comment by johan.ha...@gmail.com on 14 May 2014 at 6:31

GoogleCodeExporter commented 9 years ago
Hi Johan, 

Thanks for getting back to me.  I will email you a public link to this service 
later today on your gmail account.

Thanks, 
jtorres006@gmail.com

Original comment by jtorres...@gmail.com on 15 May 2014 at 12:49

GoogleCodeExporter commented 9 years ago
I've now looked into this and the problem seems to be related to this: 
http://stackoverflow.com/a/11401785. So just for curiosity, is the server 
implemented in PHP?

Anyway a work-around exists in the currently released version of REST Assured 
which is to disable DEFLATE encoding:
given().config(config().decoderConfig(decoderConfig().noContentDecoders()). ..

I've also added support for RFC 1951 in the next release:
given().config(config().decoderConfig(decoderConfig().useNoWrapForInflatedStream
s(true)). ..

You can of course also configure this once and for all:
RestAssured.config = 
config().decoderConfig(decoderConfig().useNoWrapForInflatedStreams(true));

Original comment by johan.ha...@gmail.com on 3 Jun 2014 at 6:56