diff options
-rw-r--r-- | test/net/http/utils.rb | 13 |
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 |