From a0b39e15d883decd916a2d1b4b67d29f503a3a7a Mon Sep 17 00:00:00 2001 From: Shai Rosenfeld Date: Tue, 28 Feb 2012 20:55:53 -0800 Subject: [PATCH] Content-Length for GET requests with an empty body 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). --- lib/excon/connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/excon/connection.rb b/lib/excon/connection.rb index d4680061..a101c831 100644 --- a/lib/excon/connection.rb +++ b/lib/excon/connection.rb @@ -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