1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

it shouldn't espace cookie

This commit is contained in:
Julien Kirch 2010-06-03 21:18:48 +02:00
parent 71552b3416
commit 28ac3d95f6
4 changed files with 9 additions and 3 deletions

View file

@ -6,6 +6,7 @@
- added parameter passing for get request using the :param key in header
- the warning about the logger when using a string was a bad idea
- multipart parameters names should not be escaped
- remove the cookie escaping introduced by migrating to CGI cookie parsing in 1.5.1
# 1.5.1

View file

@ -27,7 +27,7 @@ module RestClient
@cookies ||= (self.headers[:set_cookie] || {}).inject({}) do |out, cookie_content|
CGI::Cookie::parse(cookie_content).each do |key, cookie|
unless ['expires', 'path'].include? key
out[key] = cookie.value[0] || ''
out[CGI::escape(key)] = cookie.value[0] ? (CGI::escape(cookie.value[0]) || '') : ''
end
end
out

View file

@ -85,7 +85,7 @@ module RestClient
def make_headers user_headers
unless @cookies.empty?
user_headers[:cookie] = @cookies.map { |(key, val)| "#{key.to_s}=#{val}" }.sort.join(';')
user_headers[:cookie] = @cookies.map { |(key, val)| "#{key.to_s}=#{CGI::unescape(val)}" }.sort.join(';')
end
headers = stringify_headers(default_headers).merge(stringify_headers(user_headers))
headers.merge!(@payload.headers) if @payload

View file

@ -53,7 +53,12 @@ describe RestClient::AbstractResponse do
it "extract strange cookies" do
@net_http_res.should_receive(:to_hash).and_return('set-cookie' => ['session_id=ZJ/HQVH6YE+rVkTpn0zvTQ==; path=/'])
@response.cookies.should == { 'session_id' => 'ZJ/HQVH6YE rVkTpn0zvTQ==' }
@response.cookies.should == { 'session_id' => 'ZJ%2FHQVH6YE+rVkTpn0zvTQ%3D%3D' }
end
it "doesn't escape cookies" do
@net_http_res.should_receive(:to_hash).and_return('set-cookie' => ['session_id=BAh7BzoNYXBwX25hbWUiEGFwcGxpY2F0aW9uOgpsb2dpbiIKYWRtaW4%3D%0A--08114ba654f17c04d20dcc5228ec672508f738ca; path=/'])
@response.cookies.should == { 'session_id' => 'BAh7BzoNYXBwX25hbWUiEGFwcGxpY2F0aW9uOgpsb2dpbiIKYWRtaW4%3D%0A--08114ba654f17c04d20dcc5228ec672508f738ca' }
end
it "can access the net http result directly" do