Followed up https://github.com/ruby/net-http/commit/002441da1e for ruby/spec
This commit is contained in:
parent
82e3312493
commit
a976fa1bb7
Notes:
git
2025-06-11 04:57:21 +00:00
@ -25,9 +25,11 @@ describe "Net::HTTP.post" do
|
||||
response.should be_kind_of(Net::HTTPResponse)
|
||||
end
|
||||
|
||||
it "sends Content-Type: application/x-www-form-urlencoded by default" do
|
||||
response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request/header"), "test=test")
|
||||
response.body.should include({ "Content-Type" => "application/x-www-form-urlencoded" }.inspect.delete("{}"))
|
||||
ruby_version_is ""..."3.5" do
|
||||
it "sends Content-Type: application/x-www-form-urlencoded by default" do
|
||||
response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request/header"), "test=test")
|
||||
response.body.should include({ "Content-Type" => "application/x-www-form-urlencoded" }.inspect.delete("{}"))
|
||||
end
|
||||
end
|
||||
|
||||
it "does not support HTTP Basic Auth" do
|
||||
|
@ -31,18 +31,20 @@ describe "Net::HTTPGenericRequest#exec when passed socket, version, path" do
|
||||
end
|
||||
|
||||
describe "when a request body is set" do
|
||||
it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do
|
||||
request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path")
|
||||
request.body = "Some Content"
|
||||
ruby_version_is ""..."3.5" do
|
||||
it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do
|
||||
request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path")
|
||||
request.body = "Some Content"
|
||||
|
||||
request.exec(@buffered_socket, "1.1", "/some/other/path")
|
||||
str = @socket.string
|
||||
request.exec(@buffered_socket, "1.1", "/some/other/path")
|
||||
str = @socket.string
|
||||
|
||||
str.should =~ %r[POST /some/other/path HTTP/1.1\r\n]
|
||||
str.should =~ %r[Accept: \*/\*\r\n]
|
||||
str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n]
|
||||
str.should =~ %r[Content-Length: 12\r\n]
|
||||
str[-16..-1].should == "\r\n\r\nSome Content"
|
||||
str.should =~ %r[POST /some/other/path HTTP/1.1\r\n]
|
||||
str.should =~ %r[Accept: \*/\*\r\n]
|
||||
str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n]
|
||||
str.should =~ %r[Content-Length: 12\r\n]
|
||||
str[-16..-1].should == "\r\n\r\nSome Content"
|
||||
end
|
||||
end
|
||||
|
||||
it "correctly sets the 'Content-Length' header and includes the body" do
|
||||
@ -62,19 +64,21 @@ describe "Net::HTTPGenericRequest#exec when passed socket, version, path" do
|
||||
end
|
||||
|
||||
describe "when a body stream is set" do
|
||||
it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do
|
||||
request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path",
|
||||
"Content-Length" => "10")
|
||||
request.body_stream = StringIO.new("a" * 20)
|
||||
ruby_version_is ""..."3.5" do
|
||||
it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do
|
||||
request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path",
|
||||
"Content-Length" => "10")
|
||||
request.body_stream = StringIO.new("a" * 20)
|
||||
|
||||
request.exec(@buffered_socket, "1.1", "/some/other/path")
|
||||
str = @socket.string
|
||||
request.exec(@buffered_socket, "1.1", "/some/other/path")
|
||||
str = @socket.string
|
||||
|
||||
str.should =~ %r[POST /some/other/path HTTP/1.1\r\n]
|
||||
str.should =~ %r[Accept: \*/\*\r\n]
|
||||
str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n]
|
||||
str.should =~ %r[Content-Length: 10\r\n]
|
||||
str[-24..-1].should == "\r\n\r\naaaaaaaaaaaaaaaaaaaa"
|
||||
str.should =~ %r[POST /some/other/path HTTP/1.1\r\n]
|
||||
str.should =~ %r[Accept: \*/\*\r\n]
|
||||
str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n]
|
||||
str.should =~ %r[Content-Length: 10\r\n]
|
||||
str[-24..-1].should == "\r\n\r\naaaaaaaaaaaaaaaaaaaa"
|
||||
end
|
||||
end
|
||||
|
||||
it "sends the whole stream, regardless of the 'Content-Length' header" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user