Class: Racknga::Middleware::NginxRawURI — racknga - ラングバ

Class: Racknga::Middleware::NginxRawURI

Inherits:
Object
  • Object
show all
Defined in:
lib/racknga/middleware/nginx_raw_uri.rb

Overview

NOTE: This is a middleware that restores the unprocessed URI client requests as is. Usually, nginx-passenger stack unescapes percent encoding in URI and resolve relative paths (ie “.” and “..”). Most of time, processed URI isn’t program. However, if you want to distinguish %2F (ie “/”) from “/”, it is.

Passenger 3.x or later is required.

Use this with following nginx configuration:

... {
   ...
   passenger_set_cgi_param HTTP_X_RAW_REQUEST_URI $request_uri;
}

Usage:

require "racknga"
use Racknga::Middleware::NginxRawURI
run YourApplication

Constant Summary

RAW_REQUEST_URI_HEADER_NAME =
"HTTP_X_RAW_REQUEST_URI"

Instance Method Summary (collapse)

Constructor Details

- (NginxRawURI) initialize(application)

A new instance of NginxRawURI



43
44
45
# File 'lib/racknga/middleware/nginx_raw_uri.rb', line 43

def initialize(application)
  @application = application
end

Instance Method Details

- (Object) call(environment)

For Rack.



48
49
50
51
52
53
54
55
56
# File 'lib/racknga/middleware/nginx_raw_uri.rb', line 48

def call(environment)
  raw_uri = environment[RAW_REQUEST_URI_HEADER_NAME]

  if raw_uri
    restore_raw_uri(environment, raw_uri)
  end

  @application.call(environment)
end