cmullaparthi / ibrowse

Erlang HTTP client
Other
516 stars 190 forks source link

Clarify on trace ? #134

Closed crquan closed 9 years ago

crquan commented 9 years ago

from erlang shell I did ibrowse:trace_on() or call trace_on/2 with specific host:port, then do ibrowse:send_seq(...) I can't see any difference, where I expect it print in verbose mode on what kind of request headers & body were sent, but can see nothing,

I did some online search but couldn't find an example http://erlang.org/pipermail/erlang-questions/2013-June/074248.html

where in the example of trace, this sounds like trace as http verb, I get "Error 405 : Method Not Allowed", do you still have another web site support this trace as verb?

21> ibrowse:send_req("http://www.bbc.co.uk/", [], trace).
{ok,"405",
    [{"Content-Type","text/html"},
     {"Date","Tue, 04 Aug 2015 23:27:50 GMT"},
     {"Connection","Keep-Alive"},
     {"Allow","GET,HEAD"},
     {"Content-Length","55044"}],
    "\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-GB\" lang=\"en-GB\">\n
<head profile=\"http://dublincore.org/documents/dcq-html/\"><title>
BBC - Error 405 : Method Not Allowed
cmullaparthi commented 9 years ago

Hi,

This is what I see when I turn on tracing for an endpoint. And I'm not aware of a website which supports the TRACE method.

2> ibrowse:trace_on("www.google.com", 80).
ok

4> ibrowse:send_req("http://www.google.com", [], get).
2015-8-5_7:0:50:976 -- (www.google.com:80) - Connecting...
2015-8-5_7:0:51:30 -- (www.google.com:80) - Connected! Socket: #Port<0.764>
2015-8-5_7:0:51:30 -- (www.google.com:80) - Sending request: 
--- Request Begin ---
GET / HTTP/1.1
Host: www.google.com
Content-Length: 0

--- Request End ---
2015-8-5_7:0:51:30 -- (www.google.com:80) - Sending request body: 
--- Request Body Begin ---

--- Request Body End ---
2015-8-5_7:0:51:71 -- (www.google.com:80) - Data recvd in state: get_header. Size: 527. <<"HTTP/1.1 302 Found\r\nCache-Control: private\r\nContent-Type: text/html; charset=UTF-8\r\nLocation: http://www.google.co.uk/?gfe_rd=cr&ei=TabBVYOpFomI7Aat5bqwCQ\r\nContent-Length: 261\r\nDate: Wed, 05 Aug 2015 05:59:41 GMT\r\nServer: GFE/2.0\r\nAlternate-Protocol: 80:quic,p=0\r\n\r\n<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n<TITLE>302 Moved</TITLE></HEAD><BODY>\n<H1>302 Moved</H1>\nThe document has moved\n<A HREF=\"http://www.google.co.uk/?gfe_rd=cr&amp;ei=TabBVYOpFomI7Aat5bqwCQ\">here</A>.\r\n</BODY></HTML>\r\n">>

2015-8-5_7:0:51:72 -- (www.google.com:80) - Recvd Header Data -> HTTP/1.1 302 Found
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Location: http://www.google.co.uk/?gfe_rd=cr&ei=TabBVYOpFomI7Aat5bqwCQ
Content-Length: 261
Date: Wed, 05 Aug 2015 05:59:41 GMT
Server: GFE/2.0
Alternate-Protocol: 80:quic,p=0
----
2015-8-5_7:0:51:72 -- (www.google.com:80) - Recvd headers
--- Headers Begin ---
HTTP/1.1 302 Found
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Location: http://www.google.co.uk/?gfe_rd=cr&ei=TabBVYOpFomI7Aat5bqwCQ
Content-Length: 261
Date: Wed, 05 Aug 2015 05:59:41 GMT
Server: GFE/2.0
Alternate-Protocol: 80:quic,p=0
--- Headers End ---

2015-8-5_7:0:51:73 -- (www.google.com:80) - HttpVsn: "HTTP/1.1" StatusCode: "302" Headers_1 -> [{"Cache-Control","private"},{"Content-Type","text/html; charset=UTF-8"},{"Location","http://www.google.co.uk/?gfe_rd=cr&ei=TabBVYOpFomI7Aat5bqwCQ"},{"Content-Length","261"},{"Date","Wed, 05 Aug 2015 05:59:41 GMT"},{"Server","GFE/2.0"},{"Alternate-Protocol","80:quic,p=0"}]
2015-8-5_7:0:51:73 -- (www.google.com:80) - Recvd Content-Length of 261
{ok,"302",
    [{"Cache-Control","private"},
     {"Content-Type","text/html; charset=UTF-8"},
     {"Location",
      "http://www.google.co.uk/?gfe_rd=cr&ei=TabBVYOpFomI7Aat5bqwCQ"},
     {"Content-Length","261"},
     {"Date","Wed, 05 Aug 2015 05:59:41 GMT"},
     {"Server","GFE/2.0"},
     {"Alternate-Protocol","80:quic,p=0"}],
    "<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n<TITLE>302 Moved</TITLE></HEAD><BODY>\n<H1>302 Moved</H1>\nThe document has moved\n<A HREF=\"http://www.google.co.uk/?gfe_rd=cr&amp;ei=TabBVYOpFomI7Aat5bqwCQ\">here</A>.\r\n</BODY></HTML>\r\n"}
5> 2015-8-5_7:1:1:76 -- (www.google.com:80) - Inactivity timeout triggered. Shutting down connection
crquan commented 9 years ago

When I ran ibrowse:trace_on/0 I expect it turn on tracing for all connections? but it does nothing

106> ibrowse:trace_on().                              
{trace,true}
crquan commented 9 years ago

if I do ibrowse:trace_on/2 today that indeed works, not sure why it wasn't working yesterday.

but then what is ibrowse:trace_on/0 ?

cmullaparthi commented 9 years ago

It is only for turning on trace for the 'ibrowse' process. It used to have more trace messages, but there is hardly any at the moment so the trace_on/0 and trace_off/0 calls are actually redundant.