[erlang-bugs] Changing HTTP request version in inets http module caused warning logs

Chaos Wang chaoslawful@REDACTED
Tue Dec 9 05:14:27 CET 2008


Hi,

I'm running Erlang OTP/R12B5 with inets-5.0.12, and want to send a 
request using http:request/4 function in HTTP/1.0 instead of the default 
HTTP/1.1. When I call it like this:

    
http:request('head',{"http://www.erlang.org",[]},[{version,"HTTP/1.0"}],[]).

There will be a warning said:
   
    =INFO REPORT==== 9-Dec-2008::11:52:12 ===
    Invalid option {version,"HTTP/1.0"} ignored

But actually the request type has been changed to HTTP/1.0.

After tracking down into inets source, I find that the following code in 
inets-5.0.12/src/http.erl:266 (in http:handle_request/6)

    ...
    Version = http_util:to_upper(proplists:get_value(version,
                            HTTPOptions, "HTTP/1.1")),
    ...

which treat the value of version property as a string. But in 
inets-5.0.12/src/http.erl:364 (in http:http_options/2)

    ...
    http_options([{version, Val} | Settings], Acc)
          when is_atom(Val)->
            http_options(Settings, Acc#http_options{version = Val});
    ...

treat the value of version property as an atom. And this is the origin 
of the warning log.

So it looks like inets httpc treated the type of 'version' property 
inconsistently.




More information about the erlang-bugs mailing list