Skip to content

Commit

Permalink
Content-Length for GET requests with an empty body
Browse files Browse the repository at this point in the history
Is zero. Even though the HTTP spec doesn't forbid sending a body in a
GET request, it's generally not reccomended to send a body via GET. Some
servers behave oddly with a Content-Length of 0 on a GET request since
it seems there are realted security vulnerabilities (IIS, I believe).
  • Loading branch information
shaiguitar committed Feb 29, 2012
1 parent f12ca9a commit a0b39e1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/excon/connection.rb
Expand Up @@ -175,7 +175,7 @@ def request_kernel(params, &block)
request << HTTP_1_1

# calculate content length and set to handle non-ascii
unless params[:headers].has_key?('Content-Length')
unless params[:headers].has_key?('Content-Length') || (params[:method].to_s.upcase == "GET" && params[:body].to_s.empty?)
params[:headers]['Content-Length'] = case params[:body]
when File
params[:body].binmode
Expand Down

0 comments on commit a0b39e1

Please sign in to comment.