Skip to content

Commit

Permalink
fix content-length setting
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed Jun 22, 2010
1 parent 11cd2db commit ebd1ae6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/excon/connection.rb
Expand Up @@ -27,16 +27,15 @@ def request(params, &block)
request << " HTTP/1.1\r\n"
params[:headers] ||= @connection[:headers]
params[:headers]['Host'] ||= params[:host] || @connection[:host]
unless params[:headers]['Content-Length']
params[:headers]['Content-Length'] = (params[:body] && params[:body].length) || 0
end
params[:body] ||= @connection[:body]
params[:headers]['Content-Length'] = (params[:body] && params[:body].length) || 0
for key, value in params[:headers]
request << "#{key}: #{value}\r\n"
end
request << "\r\n"
socket.write(request)

if params[:body] ||= @connection[:body]
if params[:body]
if params[:body].is_a?(String)
socket.write(params[:body])
else
Expand Down

0 comments on commit ebd1ae6

Please sign in to comment.