Project

General

Profile

Feature #6482

Add URI requested to Net::HTTP request and response objects

Added by drbrain (Eric Hodel) about 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Target version:
[ruby-core:45193]

Description

=begin
This patch adds the full URI requested to Net::HTTPRequest and Net::HTTPResponse.

The goal of this is to make it easier to handle Location, Refresh, meta-headers, and URIs in retrieved documents. (While the HTTP RFC specifies the Location must be an absolute URI, not every server follows the RFC.) In order to process redirect responses from bad servers or relative URIs in requested documents the user must create an object that contains both the requested URI and the response object to create absolute URIs. This patch reduces the amount of boilerplate they are required to write.

Only the (({request_uri})) is used from the URI given when creating a request. The URI is stored internally and updated with the host, port and scheme used to make the request at request time. The URI is then copied to the response object for use by the user.

To preserve backwards compatibility the new behavior is optional. This allows requests with invalid URI paths like (({Net::HTTP::Get.new '/f%'})) to continue to work. Users of string paths will not be able to retrieve the requested URI.

This patch is for support of #5064
=end


Files

net.http.request_response_uri.patch (12.9 KB) net.http.request_response_uri.patch drbrain (Eric Hodel), 05/23/2012 11:48 AM
net.http.request_response_uri.2.patch (14.1 KB) net.http.request_response_uri.2.patch Currently you can't use a Net::HTTPRequest for multiple hosts since the Host header is filled in, so my patch matches current behavior. drbrain (Eric Hodel), 06/07/2012 10:02 AM
net.http.request_response_uri.3.patch (9.94 KB) net.http.request_response_uri.3.patch Remove bit rot from patch 2 drbrain (Eric Hodel), 07/21/2012 08:16 AM
net.http.request_response_uri.4.patch (10.5 KB) net.http.request_response_uri.4.patch drbrain (Eric Hodel), 12/20/2012 02:11 PM

Related issues

Related to Ruby master - Feature #5064: HTTP user-agent classAssignedmatz (Yukihiro Matsumoto)Actions

Also available in: Atom PDF