response header handling, possible bug? #242

Closed
rollator opened this Issue Jan 6, 2015 · 5 comments

Projects

None yet

2 participants

@rollator
rollator commented Jan 6, 2015

When I get a response header like this:
{"Server"=>"nginx", "Date"=>"Tue, 06 Jan 2015 21:10:14 GMT", "Content-Type"=>"text/html; charset=utf-8", "Transfer-Encoding"=>"chunked", "Connection"=>"keep-alive", "Set-Cookie"=>"no_remember=0; expires=Wed, 06-Jan-2016 23:10:14 GMT; Max-Age=31536000; path=/; domain=.foo.com; httponly", "X-UA-Compatible"=>"IE=edge,chrome=1"}

My httpclient object will print 'Unknown key: Max-Age = 31536000' to stdout. Is this a bug or intended behaviour? Could I somehow suppress this message?

@nahi nahi added the BUG label Jan 7, 2015
@rollator
rollator commented Jan 7, 2015

Would you possibly know a temporal solution which could suppress this output, so my stdout won't get flooded if I happen to receive a lot of those headers? :/

@nahi
Owner
nahi commented Jan 7, 2015

Please wait for a moment, I'm going to try to reproduce this on my end.

@nahi nahi removed the BUG label Jan 7, 2015
@nahi
Owner
nahi commented Jan 7, 2015

I can reproduce that warning;

% ruby -rhttpclient/cookie -e 'cm = HTTPClient::CookieManager.new; cm.parse("no_remember=0; expires=Wed, 06-Jan-2016 23:10:14 GMT; Max-Age=31536000; path=/; domain=.foo.com; httponly", URI("http://www.foo.com/")); cm.cookies'

And I found that old cookie implementation does not support 'Max-Age'. It's an usual Ruby's warning so you can simply ignore that, and if you want to disable all Ruby warnings you can set;

$VERBOSE = nil

such as;

% ruby -rhttpclient/webagent-cookie -e '$VERBOSE = nil; cm = HTTPClient::CookieManager.new; cm.parse("no_remember=0; expires=Wed, 06-Jan-2016 23:10:14 GMT; Max-Age=31536000; path=/; domain=.foo.com; httponly", URI("http://www.foo.com/")); cm.cookies'
@rollator
rollator commented Jan 7, 2015

Thanks a lot for your help and stay awesome :D

@nahi
Owner
nahi commented Jan 7, 2015

Closing. With httpclient/2.6.0.1 and % gem install http-cookie should parse Max-Age properly, though you might see other warnings.

@nahi nahi closed this Jan 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment