|
31 | 31 | end |
32 | 32 |
|
33 | 33 | describe "when a request body is set" do |
34 | | - it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do |
35 | | - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") |
36 | | - request.body = "Some Content" |
37 | | - |
38 | | - request.exec(@buffered_socket, "1.1", "/some/other/path") |
39 | | - str = @socket.string |
40 | | - |
41 | | - str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] |
42 | | - str.should =~ %r[Accept: \*/\*\r\n] |
43 | | - str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n] |
44 | | - str.should =~ %r[Content-Length: 12\r\n] |
45 | | - str[-16..-1].should == "\r\n\r\nSome Content" |
| 34 | + ruby_version_is ""..."3.5" do |
| 35 | + it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do |
| 36 | + request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") |
| 37 | + request.body = "Some Content" |
| 38 | + |
| 39 | + request.exec(@buffered_socket, "1.1", "/some/other/path") |
| 40 | + str = @socket.string |
| 41 | + |
| 42 | + str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] |
| 43 | + str.should =~ %r[Accept: \*/\*\r\n] |
| 44 | + str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n] |
| 45 | + str.should =~ %r[Content-Length: 12\r\n] |
| 46 | + str[-16..-1].should == "\r\n\r\nSome Content" |
| 47 | + end |
46 | 48 | end |
47 | 49 |
|
48 | 50 | it "correctly sets the 'Content-Length' header and includes the body" do |
|
62 | 64 | end |
63 | 65 |
|
64 | 66 | describe "when a body stream is set" do |
65 | | - it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do |
66 | | - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path", |
67 | | - "Content-Length" => "10") |
68 | | - request.body_stream = StringIO.new("a" * 20) |
69 | | - |
70 | | - request.exec(@buffered_socket, "1.1", "/some/other/path") |
71 | | - str = @socket.string |
72 | | - |
73 | | - str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] |
74 | | - str.should =~ %r[Accept: \*/\*\r\n] |
75 | | - str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n] |
76 | | - str.should =~ %r[Content-Length: 10\r\n] |
77 | | - str[-24..-1].should == "\r\n\r\naaaaaaaaaaaaaaaaaaaa" |
| 67 | + ruby_version_is ""..."3.5" do |
| 68 | + it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do |
| 69 | + request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path", |
| 70 | + "Content-Length" => "10") |
| 71 | + request.body_stream = StringIO.new("a" * 20) |
| 72 | + |
| 73 | + request.exec(@buffered_socket, "1.1", "/some/other/path") |
| 74 | + str = @socket.string |
| 75 | + |
| 76 | + str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] |
| 77 | + str.should =~ %r[Accept: \*/\*\r\n] |
| 78 | + str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n] |
| 79 | + str.should =~ %r[Content-Length: 10\r\n] |
| 80 | + str[-24..-1].should == "\r\n\r\naaaaaaaaaaaaaaaaaaaa" |
| 81 | + end |
78 | 82 | end |
79 | 83 |
|
80 | 84 | it "sends the whole stream, regardless of the 'Content-Length' header" do |
|
0 commit comments