Premature end of Content-Length delimited message body

1,785 views
Skip to first unread message

SPG

unread,
Feb 1, 2018, 7:05:34 AM2/1/18
to REST assured
Hi!

I have problems in a call to an Api Rest. The answer takes between 4-7s to answer and when it does and I'm going to pick up the body I get the following error:

org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 217; received: 115
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:178)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135)
at org.apache.http.conn.EofSensorInputStream$read.call(Unknown Source)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.convertStreamToByteArray(RestAssuredResponseOptionsGroovyImpl.groovy:463)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:206)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.charsetToString(RestAssuredResponseOptionsGroovyImpl.groovy:515)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl$charsetToString$3.callCurrent(Unknown Source)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.asString(RestAssuredResponseOptionsGroovyImpl.groovy:181)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.asString(RestAssuredResponseOptionsGroovyImpl.groovy:177)
at io.restassured.internal.RestAssuredResponseOptionsGroovyImpl.print(RestAssuredResponseOptionsGroovyImpl.groovy:155)
at io.restassured.internal.RestAssuredResponseOptionsImpl.print(RestAssuredResponseOptionsImpl.java:224)
at bbva.cucumber.steps.CreateAccountStepdefs.lambda$1(CreateAccountStepdefs.java:86)
at ✽.a new account should be created with 201 status code(features/post-account.feature:20)


Call:
given().headers(commonRequestStepdefs.getHeaders())
       .body(bodyJson).log().all()
   .when().post(accountPostPath)
   .then().statusCode(statusCode)
   .body(matchesJsonSchemaInClasspath(jsonSchema));


Expected response:
Status code: 201
Body: {"account_id":"AC-0354afa5-5412-4c6f-9d68-a7e82w321327","account_number":"0309874187","routing_number":"062874186"}

If I delete the .body (matchesJsonSchemaInClasspath (jsonSchema)) statement, everything goes correctly, but when I want to pick up the body, I get the error.
 
I have tried to configure the connection according to the documentation as well as extend the call timeout (with HttpClientConfig) but nothing has worked. 

I've been searching the internet for several days, but I can not find the solution and I do not have any more ideas.

Thank you!

Nota legal: Este mensaje y cualquier archivo adjunto está destinado únicamente a la persona a quien se dirige y es confidencial. Si usted ha recibido este mensaje por error, por favor, comuníqueselo al remitente y bórrelo inmediatamente. La utilización, revelación y/o reproducción del mensaje puede constituir un delito.

Protección de Datos: Le informamos que sus datos de contacto electrónico están siendo tratados de acuerdo con la normativa de la Ley de Protección de Datos, hallándose incorporados a un fichero titularidad de KAIROS DIGITAL ANALITYCS AND BIG DATA SOLUTIONS, S.L., al objeto de envío de información,  respuesta a consultas y contactos genéricos. 

Puede ejercer los derechos de acceso, rectificación, cancelación y oposición en cualquier momento, mediante escrito, acompañado de copia de documento oficial que le identifique, dirigido a KAIROS DIGITAL ANALITYCS AND BIG DATA SOLUTIONS, S.L., con domicilio social en C/ CLAUDIO COELLO, 78, 28001 – MADRID. También podrá oponerse a nuestros envíos de comunicaciones comerciales (Art.21.2 de la LSSI) a través de la siguiente dirección de correo electrónico: adminis...@kairosds.com

Todd Bradley

unread,
Feb 1, 2018, 9:59:54 AM2/1/18
to rest-a...@googlegroups.com
If you can’t think of any other way to make this work, why not remove the matcher in the .body() call and let the whole thing return a ValidateableResponse. Then you can extract the body out of that as a string and apply your matcher separately. 


Todd. 


--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Sent from Gmail Mobile
Reply all
Reply to author
Forward
0 new messages