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

Serge Aleynikov saleyn@REDACTED
Fri Oct 31 12:50:40 CET 2008


Thanks all who answered!  Unfortunately the embedded http server I am 
pulling this data from doesn't support range headers.  Or maybe I am 
using it incorrectly?  Here's what request looked like:

     http:request(get, {Url, [{"Range", "bytes=0-100"}]},
         [{body_format, binary},{full_result, false}]).

Tried the same with Url="www.google.com" and a couple of other sites 
without success.

I was hoping there was a way to do this in synchronous mode, so that I 
wouldn't need to assemble binary response chunks...

Actually the full_result option is seems to be useful if you don't care 
about headers.

Here's one correction to documentation:

	body_format() = string() | binary()

should be:

	body_format() = string | binary

Serge

Ingela Anderton Andin wrote:
> Hi!
> 
> 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 
> things.  
> 
> 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