-
Notifications
You must be signed in to change notification settings - Fork 321
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
Can't convert Array into String. (TypeError) #585
Comments
Ah, maybe it is the expected behaviour of the parser, root@8b3b9a934e9b:/app# irb -rhttp
irb(main):001:0> HTTP.get("https://burd.se/httprb2").headers["Location"].class
=> Array
irb(main):002:0> HTTP.get("https://burd.se/httprb2").headers["Location"].size
=> 3 |
We don't use It's a bug of HTTP::Redirector (which I really need to extract out of the client I believe). So, basically bug is caused by my mistake in Easiest fix will be to change this line: Line 61 in 968e4f4
To something like: @request = redirect_to @response.headers.get(Headers::LOCATION).first Alternatively we can fail in this case (with a bit more meaningful message though) when multiple Location headers per RFC 7320 Section 3.2.2 which allows only See Also |
@ixti the problem isn't multiple location headers, there's only one for https://burd.se/httprb2, it's just that it's very long :) It works in both Google Chrome and |
I should correct myself, I only see one Location header with Chrome and curl, but maybe they work around it? |
@dentarg Hmm. Seems like their logic is actually: @response.headers.get(Headers::LOCATION).join But server is definitely sending 3 Location headers: require "http"
require "logger"
HTTP.use(:logging => { :logger => Logger.new(STDOUT) }).get("https://burd.se/httprb2") You will see something like this:
|
Thanks for checking that, I guess it makes sense, I assume there's some limit on how big HTTP headers are allowed to be. Either joining them or raising an |
I tend to follow what Firefox, curl, and Chrome are doing - and will simply concatenate those. |
This looks like a bug in the HTTP parser used (https://github.com/tmm1/http_parser.rb), but I thought I would first report it here. (I haven't yet taken the time to reproduce it with only http_parser.rb.)
The bug happens when you try to follow really long redirect URLs. In my case the URL have the whole page content embedded, that's why it's so long (see https://github.com/alcor/itty-bitty/). https://burd.se/httprb2 is an example that redirect to such an URL.
Repro:
I suspect it is the parser, because with this patch
This is the output
The text was updated successfully, but these errors were encountered: