[erlang-questions] Erlang HTTP client is not so fault tollerant...

Timmy Turner timm.turn@REDACTED
Sun Dec 9 14:07:29 CET 2007


Hi there,

a normal HTTP 301 response should look like this:

HTTP/1.1 301 Moved Permanently
Date: Sun, 09 Dec 2007 10:54:02 GMT
Server: Apache/1.3.37 (Unix) PHP/4.4.4 with Suhosin-Patch
FrontPage/5.0.2.4803 mod_fastcgi/mod_fastcgi-SNAP-0404142202 mod_ssl/2.8.28
OpenSSL/0.9.6i
Location: http://www.spielendverdienen.de/startseite.html

However, some servers return

HTTP/1.1 301
Date: Sun, 09 Dec 2007 10:52:58 GMT
Server: Apache/1.3.37 (Unix) FrontPage/5.0.2.2623 mod_ssl/2.8.28
OpenSSL/0.9.8a
Location: http://charmed.qanet.de/en/

(notice the first line, in the second response the reason is missing)

When requesting a page from a server that returns the second http-response,
erlang crashes:

27> http:request("http://charmed.qanet.de/",foo).
{error,{badarg,[{erlang,list_to_integer,["301\r\nDate:"]},
                {httpc_response,parse_status_code,4},
                {httpc_handler,handle_info,2},
                {gen_server,handle_msg,5},
                {proc_lib,init_p,5}]}}

=ERROR REPORT==== 9-Dec-2007::14:04:08 ===
** Generic server <0.106.0> terminating
** Last message in was {tcp,#Port<0.185>,
                            <<"HTTP/1.1 301\r\nDate: Sun, 09 Dec 2007
13:04:18 G
MT\r\nServer: Apache/1.3.37 (Unix) FrontPage/5.0.2.2623 mod_ssl/2.8.28
OpenSSL/0
.9.8a\r\nLocation: http://charmed.qanet.de/en/\r\nKeep-Alive: timeout=15,
max=10
0\r\nConnection: Keep-Alive\r\nTransfer-Encoding: chunked\r\nContent-Type:
text/
html\r\n\r\n">>}
** When Server state == {state,
                            {request,#Ref<0.0.0.444>,<0.62.0>,0,http,
                                {"charmed.qanet.de",80},
                                "/",[],get,
                                {http_request_h,undefined,"keep-alive",
                                    undefined,undefined,undefined,undefined,
                                    undefined,undefined,undefined,undefined,
                                    undefined,undefined,undefined,undefined,
                                    undefined,undefined,"charmed.qanet.de",
                                    undefined,undefined,undefined,undefined,
                                    undefined,undefined,undefined,undefined,
                                    undefined,[],undefined,undefined,
                                    undefined,undefined,"0",undefined,
                                    undefined,undefined,undefined,undefined,
                                    undefined,[]},
                                {[],[]},
                                {http_options,infinity,true,[],undefined,
                                    false},
                                "http://charmed.qanet.de/",[],none,[]},
                            {tcp_session,
                                {{"charmed.qanet.de",80},<0.106.0>},
                                false,http,#Port<0.185>,1},
                            undefined,undefined,undefined,
                            {httpc_response,parse,[nolimit]},
                            {[],[]},
                            new,[],nolimit,nolimit,
                            {options,
                                {undefined,[]},
                                0,2,2,enabled,enabled,false},
                            {timers,[],undefined},
                            httpc_manager_foo,undefined}
** Reason for termination ==
** {badarg,[{erlang,list_to_integer,["301\r\nDate:"]},
            {httpc_response,parse_status_code,4},
            {httpc_handler,handle_info,2},
            {gen_server,handle_msg,5},
            {proc_lib,init_p,5}]}
28>

Therefore, I'd like to replace the first line of the incoming server
response from "HTTP/1.1 301\r\n" to "HTTP/1.1 301 Moved Permanently\r\n",
but I can't seem to find where the appropriate to do so would be...

Can you help me with this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20071209/f7619e58/attachment.htm>


More information about the erlang-questions mailing list