New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow viewing request headers #8
Conversation
|
bump |
|
@coreydaley ptal |
config.ru
Outdated
| headers = proc do |env| | ||
| [200, { "Content-Type" => "text/html" }, [ | ||
| env.select {|key,val| key.start_with? 'HTTP_'} | ||
| .collect {|key, val| [key.sub(/^HTTP_/, ''), val]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave the HTTP_ prefix on the headers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original headers don't have HTTP_ prefix. AFAIK it is rack that puts them into env by adding the prefix. So HTTP_ is not actually part of the header name. See http://www.rubydoc.info/github/rack/rack/file/SPEC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine then.
config.ru
Outdated
| .join("<br/>\n") | ||
| ]] | ||
| end | ||
| run headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have this output properly formatted HTML as the root route does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Firefox it shows "Quirks mode". HTML is very minimal. Just <br/> for new lines and strings are HTML escaped for proper output.
In any case here is an example raw output of current implementation:
ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br/>
ACCEPT_ENCODING: gzip, deflate<br/>
ACCEPT_LANGUAGE: bg,en-US;q=0.7,en;q=0.3<br/>
COOKIE: s_fid=1C893BDD6A1DFF78-0BE36C33F7C57F7E; s_vi=[CS]v1|2CB1B999851D4D11-60000136A00064DA[AC]; AMCV_945F02BE332957400A490D4C%40AdobeOrg=-<snip for security>4882679239%26vn%3D12<br/>
DNT: 1<br/>
FORWARDED: for=10.3.2.11;host=ruby-ex-aosqe.example.com;proto=http<br/>
HOST: ruby-ex-aosqe..com<br/>
UPGRADE_INSECURE_REQUESTS: 1<br/>
USER_AGENT: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0<br/>
VERSION: HTTP/1.1<br/>
X_FORWARDED_FOR: 10.3.2.11<br/>
X_FORWARDED_HOST: ruby-ex-aosqe.example.com<br/>
X_FORWARDED_PORT: 80<br/>
X_FORWARDED_PROTO: http
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you specify more precisely what should properly formatted HTML mean? With html and head tags? Or something more? Alternatively probably this can serve text/plain instead of "text/html". WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either wrap it in html and head etc, or specifying text/plain would probably be a better solution
|
Sorry for delay, updated to send |
I checked that it looks ok in browsers as well. |
|
@bparees lgtm |
* allow viewing request headers * text/plain output for headers
* allow viewing request headers * text/plain output for headers
Made this modification to aid testing. Thought might be useful for the example.