List Info

Thread: Re: http client parse (noncompliant) status-line




Re: http client parse (noncompliant) status-line
country flaguser name
Sweden
2007-09-06 09:28:58
FYI!  (As I was not yet a member of erlang-bugs when I wrote
the answer)

Hi!

I think parsing is robust enough the client did not die, it
returned an 
error message.
However it ended up in the default clause e.i. an unexpected
error and 
hence the
error-reason was set to the call stack for what went wrong
in in the 
temporary internal
http client process that handles the request. That is the
intention 
since then
we can easily understand what went wrong if it crash in an
unexpected 
way and maybe find a better  way of handling it.

It would in this case perhaps be better to return something
like
{error, {"Response not compliant to http can not
parse", Data}}

It is not really reasonable to make the client
bug-compatible with 
apache, but
perhaps if it is a known bug and no too much work to fix, it
could be 
added to the
relaxed mode I mentioned in our earlier correspondence.
I will put this matter on the TODO list.


Regards - Ingela OTP team 

> Dear maintainers,
>
> ----------
> % erl
> Erlang (BEAM) emulator version 5.5.5 [source]
[async-threads:0]
> [kernel-poll:false]
>
> Eshell V5.5.5  (abort with ^G)
> 1> http:request ("http://g-shock.tr
end-now.net/").
>
> =INFO REPORT==== 3-Sep-2007::13:45:22 ===
> The inets application was not started. Has now been
started as a 
> temporary
> application.
>
{error,{badarg,[{erlang,list_to_integer,["302rnDate:&
quot;]},
>                 {httpc_response,parse_status_code,4},
>                 {httpc_handler,handle_info,2},
>                 {gen_server,handle_msg,6},
>                 {proc_lib,init_p,5}]}}
> ----------
>
> The response clearly violates the rfc
> (http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.htm
l#sec6.1) since
> the response phrase is missing:
>
> ----------
> % printf "GET / HTTP/1.1rnHost:
g-shock.trend-now.netrnConnection: 
> closernrn" | nc g-shock.trend-now.net 80 |
head -1 | hexdump -c
> 0000000   H   T   T   P   /   1   .   1       3   0   2
 r  n
> 000000e
> ----------
>
> and yet the server claims to be apache 2.0:
>
> ----------
> % telnet g-shock.trend-now.net 80
> ~
> Trying 208.113.213.164...
> Connected to g-shock.trend-now.net.
> Escape character is '^]'.
> GET / HTTP/1.1
> Host: g-shock.trend-now.net
> Connection: close
>
> HTTP/1.1 302
> Date: Mon, 03 Sep 2007 20:48:38 GMT
> Server: Apache/2.0.54 (Unix) PHP/4.4.7 mod_ssl/2.0.54
OpenSSL/0.9.7e 
> mod_fastcgi/2.4.2 DAV/2 SVN/1.4.2
> X-Powered-By: PHP/5.2.2
> Location: http://g-shock.brand-
items.com/
> Vary: Accept-Encoding
> Content-Length: 0
> Connection: close
> Content-Type: text/html; charset=UTF-8
>
> Connection closed by foreign host.
> ----------
>
> Anyway IMHO I think it would be good to be more robust
in the parsing of
> the response status-line.
>
> Thanks,
>
> -- p

_______________________________________________
erlang-bugs mailing list
erlang-bugserlang.org
ht
tp://www.erlang.org/mailman/listinfo/erlang-bugs

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )