[erlang-questions] inets http client (Serge Aleynikov)

Ingela Anderton Andin ingela@REDACTED
Fri Oct 31 11:38:38 CET 2008


erlang-questions-request@REDACTED wrote:
> Is there a way in http:request/4 call to limit the number of bytes 
> returned without waiting for the full content?  I have a URL to query 
> frequently where the most relevant information is in the beginning of 
> the page and the tail of the document is useless but large.
> There is {full_result, boolean()} option (that doesn't seem to be 
> documented well, so I am unclear what it does) but I don't see how to 
> limit the number of bytes to be received.
> Serge
The option {full_result, false} will acctuly just strip-away the 
http-headers and return
{ok,  {Status, Body}} and it is something that exists for backward 
compatibility reasons.
We ought to document it better or perhaps deprecate it. But we have not 
had time to focus on
these types of issues when we have been swamped with more pressing 

What you could do is to use the option {sync, false}  and when you 
received  enough info in your
process you can cancel the request.  This way you would not have to 
receive the whole body but you
may get a few more bytes than you are interested in. There is no way to 
receive just a specified number of bytes.
Or perhaps you can utilize the ranged property in the HTTP-protocol as 
suggested by others.

Regards Ingela Erlang/OTP - Ericsson


More information about the erlang-questions mailing list