summaryrefslogtreecommitdiff
path: root/test/net/http/utils.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <[email protected]>2025-06-11 10:45:41 +0900
committergit <[email protected]>2025-06-11 03:35:12 +0000
commit82e3312493a26fc56e2823c07e261d1bf61edd42 ()
treebd670513d04f0a733d5ff117eb18493b83d835ac /test/net/http/utils.rb
parent51b70d106ad2fa29f833bde5648738931981d8f4 (diff)
[ruby/net-http] Fixed test case for default content-type.
I changed content-type of request to "application/octet-stream" if request didn't have content-type. https://.com/ruby/net-http/commit/fc5870d2ac
-rw-r--r--test/net/http/utils.rb13
1 files changed, 10 insertions, 3 deletions
@@ -71,6 +71,11 @@ module TestNetHTTPUtils
socket.write "HTTP/1.1 100 Continue\r\n\r\n"
end
req = Request.new(method, path, headers, socket)
if @procs.key?(req.path) || @procs.key?("#{req.path}/")
proc = @procs[req.path] || @procs["#{req.path}/"]
@@ -306,16 +311,18 @@ module TestNetHTTPUtils
scheme = headers['X-Request-Scheme'] || 'http'
host = @config['host']
port = socket.addr[1]
- charset = parse_content_type(headers['Content-Type'])[1]
path = "#{scheme}://#{host}:#{port}#{path}"
path = path.encode(charset) if charset
- response = "HTTP/1.1 200 OK\r\nContent-Type: #{headers['Content-Type']}\r\nContent-Length: #{body.bytesize}\r\nX-request-uri: #{path}\r\n\r\n#{body}"
socket.print(response)
end
def handle_(path, headers, socket)
body = socket.read(headers['Content-Length'].to_i)
- response = "HTTP/1.1 200 OK\r\nContent-Type: #{headers['Content-Type']}\r\nContent-Length: #{body.bytesize}\r\n\r\n#{body}"
socket.print(response)
end