ruby-proxifier
ruby-proxifier copied to clipboard
Use strict Base64 encoding to prevent bad requests
With Array#pack
, if the credentials is too long, it ends up adding a
new line in the middle of the resulting base64 encoded string, which results in
a 400 Bad Request. To fix this, Base64.strict_encode64
should be used.
Bad:
CONNECT blah:80 HTTP/1.1
Proxy-Authorization: Basic YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhOmJiYmJiYmJiYmJiYmJi
YmJiYmJi
...
Good:
CONNECT blah:80 HTTP/1.1
Proxy-Authorization: Basic YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhOmJiYmJiYmJiYmJiYmJiYmJiYmJi
...