How to tell Restlet not to use the chunked trunsfer encoding.

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to tell Restlet not to use the chunked trunsfer encoding.

Mark Kharitonov
Hi.
The title says it all.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2889135
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: How to tell Restlet not to use the chunked trunsfer encoding.

Mark Kharitonov
Anyone?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2890337
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to tell Restlet not to use the chunked trunsfer encoding.

Thierry Boileau
Hello Mark,

This kind of requirement has been observed when sending data to the GAE platform which forbids chunked entities (see http://restlet.tigris.org/issues/show_bug.cgi?id=1219). In order to prevent chunk encoding, you can call the ClientResource#setRequestEntityBuffering(boolean) method with a "true" value.

Best regards,
Thierry Boileau


Anyone?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2890337

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Re: How to tell Restlet not to use the chunked trunsfer encoding.

Mark Kharitonov
There is something I do not understand. Is it the client who has to call ClientResource.setRe​questEntityBuffering​(true) ?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2891697
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Re: How to tell Restlet not to use the chunked trunsfer encoding.

Mark Kharitonov
In reply to this post by Thierry Boileau
I have searched the Restlet 2.0.10 source code for the string setRe​questEntityBuffering​ and it does not exist.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2891705
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: How to tell Restlet not to use the chunked trunsfer encoding.

Thierry Boileau
In reply to this post by Mark Kharitonov
Hello Mark,

I forgot to say the API has been updated only for the 2.1 trunk, not the 2.0 branch. There is still a workaround (see http://restlet.tigris.org/issues/show_bug.cgi?id=1219). You can have a look at the end of this mail.

>There is something I do not understand. Is it the client who has to call ClientResource.setRe​questEntityBuffering​(true) ?
yes, all happens on client side. As GAE does not support chunked entities, the client has to send an instance of Representation with a known size, by doing so the client connector won't use chunked encoding.

Best regards,
Thierry Boileau
here is an excerpt of issue 1219 (http://restlet.tigris.org/issues/show_bug.cgi?id=1219) :
A solution is to wrap the sent entity in a Representation that expand the
chunked entity, store it in memory, then calculate the size.
Or to change the behaviour of the ClientResource. It could be something like that:
ClientResource res = new ClientResource("<remoteUri>") {
@Override
protected Representation toRepresentation(Object source, Variant target) {
Representation result = null;
if (source != null) {
org.restlet.service.ConverterService cs = getConverterService();
result = cs.toRepresentation(source, target, this);
if (result != null) {
try {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
BioUtils.copy(result.getStream(), os);
OutputRepresentation rep = new OutputRepresentation(
result.getMediaType()) {
@Override
public void write(OutputStream outputStream) throws IOException {
outputStream.write(os.toByteArray());
}
};
rep.setSize(os.size());
result = rep;
} catch (IOException e) {
e.printStackTrace();
}
}
}
return result;
}
};

If all your client calls are issued from an instance of org.restlet.Application, you can use and outbound filter that copes with this feature.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Re: Re: How to tell Restlet not to use the chunked trunsfer encoding.

Mark Kharitonov
But my client side does not use Restlet. What should the HTTP request contain to tell the server not to use the chunked encoding?

Thanks.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2891906
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Re: How to tell Restlet not to use the chunked trunsfer encoding.

Thierry Boileau
Hello Mark,

in this case, I'm not sure to understand your question.
Your client sends requests to the server which may contain entities, which may be chunked, or not.
In case the entity is chunked, any server (not only restlet-based), by default, will do its best to consider the entity and recover the exact entity by concatenating all chunks sent by the client.
Do you mean to tell your server (I guess it's based on Restlet) to refuse chunked requests?

Best regards,
Thierry Boileau

But my client side does not use Restlet. What should the HTTP request contain to tell the server not to use the chunked encoding?

Thanks.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2891906

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Re: Re: Re: How to tell Restlet not to use the chunked trunsfer encoding.

Mark Kharitonov
The other way around - the server sends entities to the client and I wish that the server not used chunked transfer encoding.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2893248
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Re: Re: How to tell Restlet not to use the chunked trunsfer encoding.

jlouvel
Administrator
In reply to this post by Thierry Boileau

Hello,

 

I guess Mark is using GAE as a backend and another HTTP client than Restlet. In this case it is really about configuring your HTTP client (if possible) to not chunk the entity. This typically require to know in advance the entity size (content-length);

 

Best regards,

Jerome

--

http://www.restlet.org

http://twitter.com/#!/jlouvel

 

 

 

 

De : Thierry Boileau [mailto:[hidden email]]
Envoyé : vendredi 9 décembre 2011 18:52
À : [hidden email]
Objet : Re: Re: Re: How to tell Restlet not to use the chunked trunsfer encoding.

 

Hello Mark,

in this case, I'm not sure to understand your question.
Your client sends requests to the server which may contain entities, which may be chunked, or not.
In case the entity is chunked, any server (not only restlet-based), by default, will do its best to consider the entity and recover the exact entity by concatenating all chunks sent by the client.
Do you mean to tell your server (I guess it's based on Restlet) to refuse chunked requests?

Best regards,
Thierry Boileau

 

But my client side does not use Restlet. What should the HTTP request contain to tell the server not to use the chunked encoding?

Thanks.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2891906

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to tell Restlet not to use the chunked trunsfer encoding.

Gijs Kruitbosch-2
Note that Mark never said he was using GAE. Given that he posted to this mailing list, I'm guessing the problem is with restlet. If he's not using it as a client, that means restlet is used as a server.

At least, in my case the problem is exactly that: I'm using Restlet as a server. I don't want it to chunk the responses it serves, as gzip encoding seems to be broken in that case and I want to see if using non-chunking helps. How do I do this?

Regards,
Gijs

On 15/12/2011 10:25 AM, Jerome Louvel wrote:

Hello,

 

I guess Mark is using GAE as a backend and another HTTP client than Restlet. In this case it is really about configuring your HTTP client (if possible) to not chunk the entity. This typically require to know in advance the entity size (content-length);

 

Best regards,

Jerome

--

http://www.restlet.org

http://twitter.com/#!/jlouvel

 

 

 

 

De : Thierry Boileau [[hidden email]]
Envoyé : vendredi 9 décembre 2011 18:52
À : [hidden email]
Objet : Re: Re: Re: How to tell Restlet not to use the chunked trunsfer encoding.

 

Hello Mark,

in this case, I'm not sure to understand your question.
Your client sends requests to the server which may contain entities, which may be chunked, or not.
In case the entity is chunked, any server (not only restlet-based), by default, will do its best to consider the entity and recover the exact entity by concatenating all chunks sent by the client.
Do you mean to tell your server (I guess it's based on Restlet) to refuse chunked requests?

Best regards,
Thierry Boileau

 

But my client side does not use Restlet. What should the HTTP request contain to tell the server not to use the chunked encoding?

Thanks.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2891906

 


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Re: How to tell Restlet not to use the chunked trunsfer encoding.

Mark Kharitonov
Precisely.

I have a Restlet server and I do not want the server to respond with chunked transfer encoding. The client is irrelevant.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2894061
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Re: How to tell Restlet not to use the chunked trunsfer encoding.

Mark Kharitonov
Anyone?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2897185
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Re: How to tell Restlet not to use the chunked trunsfer encoding.

jlouvel
Administrator
Hi Mark,

Ok, we have all the info in hand now :) Restlet strategy is to use chunked
encoding when it doesn't know in advance the size of the response entity.
This is typically the case with representations based on serialized objects,
byte or character streams.

The workaround in this case is to use a buffering representation to wrap
those representations with unknown size (-1). In Restlet 2.1, there the
org.restlet.engine.io.BufferingRepresentation class that does just that. In
order to apply this workaround systematically, the best is to add a filter
to your routing chain and override the afterHandle method.

Now, regarding the issue with the compressiong combined with chunked
encoding, if there is an issue/bug it should be reported. Does this happen
only with the internal connector in v2.1 or with other settings?

Best regards,
Jerome
--
http://www.restlet.org
http://twitter.com/#!/jlouvel



-----Message d'origine-----
De : Mark Kharitonov [mailto:[hidden email]]
Envoyé : mercredi 21 décembre 2011 19:36
À : [hidden email]
Objet : RE: Re: How to tell Restlet not to use the chunked trunsfer
encoding.

Anyone?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=28971
85

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2899180
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Re: How to tell Restlet not to use the chunked trunsfer encoding.

Mark Kharitonov
Hi Jerome.

I have not encountered any compression related issues personally.

As for using BufferedRepresentation. How do I do it the best, when I am using JAX-RS? Should I register a filter and insert it after the JaxRsApplication restlet?

Thanks.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2899680
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Re: How to tell Restlet not to use the chunked trunsfer encoding.

jlouvel
Administrator
Hi Mark,

It should be a filter attached right before your JaxRsApplication,
overriding the afterHandle() method. Remember that doing so can have a
significant memory cost and isn't generally recommended. Chunked encoding is
a good thing.

Best regards,
Jerome
--
http://www.restlet.org
http://twitter.com/#!/jlouvel



-----Message d'origine-----
De : Mark Kharitonov [mailto:[hidden email]]
Envoyé : samedi 24 décembre 2011 16:00
À : [hidden email]
Objet : RE: Re: How to tell Restlet not to use the chunked trunsfer
encoding.

Hi Jerome.

I have not encountered any compression related issues personally.

As for using BufferedRepresentation. How do I do it the best, when I am
using JAX-RS? Should I register a filter and insert it after the
JaxRsApplication restlet?

Thanks.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=28996
80

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2901598
Loading...