Module: ExperellaProxy

Defined in:
lib/experella-proxy.rb,
lib/experella-proxy/proxy.rb,
lib/experella-proxy/server.rb,
lib/experella-proxy/backend.rb,
lib/experella-proxy/globals.rb,
lib/experella-proxy/request.rb,
lib/experella-proxy/version.rb,
lib/experella-proxy/response.rb,
lib/experella-proxy/connection.rb,
lib/experella-proxy/configuration.rb,
lib/experella-proxy/backend_server.rb,
lib/experella-proxy/http_status_codes.rb,
lib/experella-proxy/connection_manager.rb

Overview

Namespace Module for the Proxy Server

Startup code and options parser is defined here

Examples:

startup

ARGV << '--help' if ARGV.empty?

options = {}
OptionParser.new do |opt|
  opt.banner = "Usage: experella-proxy <command> <options> -- <application options>\n\n"
  opt.banner << "where <applicaion options> are"

  opt.on("-c", "--config=CONFIGFILE", "start server with config in given filepath") do |v|
    options[:configfile] = File.expand_path(v)
    ExperellaProxy.run(options)
  end

end.parse!

See Also:

Author:

  • Dennis-Florian Herr 2014 @Experteer GmbH

Defined Under Namespace

Modules: Globals Classes: Backend, BackendServer, Configuration, Connection, ConnectionManager, Proxy, Request, Response, Server

Constant Summary collapse

HOP_HEADERS =

defined hop by hop header fields

%w(Connection Keep-Alive Proxy-Authorization TE Trailer Transfer-Encoding Upgrade)
VERSION =

ExperellaProxy Gemversion 0.0.14

  • added error handling for unknown http status codes

0.0.13

* headers are no longer folded if they came unfolded but headers stay as is

0.0.12.WIP

* rubocop cleanup

0.0.11

  • output version on start

  • rubocup config file

  • applied rubyocop config file

0.0.10

  • no logging any more just firing events

0.0.9

  • added simplecov code coverage support.

  • removed an unescaped duplicate debug log output

0.0.8

  • fixed a parsing bug where no data was send when backend used connection close to indicate message end

0.0.7

  • fixed minor issues with ruby 2.0

  • fixed a typo in default config

  • refactored mangling in own method

  • refactored message pattern and matching

0.0.6

  • updated homepage

0.0.5

  • added :host_port option to backend configuration

0.0.4

  • added lambda for accept filtering

0.0.3

  • added self-signed SSL certificate for TLS/HTTPS

  • added config template init functionality

"0.0.14"
HTTP_STATUS_CODES =

Every standard HTTP code mapped to the appropriate message.

Author:

  • Mongrel.

{
  100 => 'Continue',
  101 => 'Switching Protocols',
  200 => 'OK',
  201 => 'Created',
  202 => 'Accepted',
  203 => 'Non-Authoritative Information',
  204 => 'No Content',
  205 => 'Reset Content',
  206 => 'Partial Content',
  300 => 'Multiple Choices',
  301 => 'Moved Permanently',
  302 => 'Moved Temporarily',
  303 => 'See Other',
  304 => 'Not Modified',
  305 => 'Use Proxy',
  400 => 'Bad Request',
  401 => 'Unauthorized',
  402 => 'Payment Required',
  403 => 'Forbidden',
  404 => 'Not Found',
  405 => 'Method Not Allowed',
  406 => 'Not Acceptable',
  407 => 'Proxy Authentication Required',
  408 => 'Request Time-out',
  409 => 'Conflict',
  410 => 'Gone',
  411 => 'Length Required',
  412 => 'Precondition Failed',
  413 => 'Request Entity Too Large',
  414 => 'Request-URI Too Large',
  415 => 'Unsupported Media Type',
  422 => 'Unprocessable Entity',
  500 => 'Internal Server Error',
  501 => 'Not Implemented',
  502 => 'Bad Gateway',
  503 => 'Service Unavailable',
  504 => 'Gateway Time-out',
  505 => 'HTTP Version not supported',
  522 => 'Uknown Error'
}

Class Method Summary collapse

Class Method Details

.configConfiguration

static getter for the config variable

Returns:



5
6
7
# File 'lib/experella-proxy/configuration.rb', line 5

def self.config
  @config
end

.config=(config) ⇒ Configuration

static setter for the config variable

Parameters:

Returns:



13
14
15
# File 'lib/experella-proxy/configuration.rb', line 13

def self.config=(config)
  @config = config
end

.connection_managerConnectionManager

static getter for the connection_manager variable

Returns:



5
6
7
# File 'lib/experella-proxy/connection_manager.rb', line 5

def self.connection_manager
  @connection_manager
end

.init(options = {}) ⇒ Boolean

Initializes ExperellaProxy’s Configuration and ConnectionManager

Parameters:

  • options (Hash) (defaults to: {})

    Hash passed to the configuration

  • option (Hash)

    a customizable set of options

Returns:

  • (Boolean)

    true if successful false if NoConfigError was raised



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/experella-proxy.rb', line 44

def self.init(options={})
  begin
    Configuration.new(options)
    rescue Configuration::NoConfigError => e
      puts e.message
      puts e.backtrace.join("\n\t")
      return false
  end
  @connection_manager = ConnectionManager.new
  true
end

.restartObject

Fresh restarts ExperellaProxy with same options.

Loses all buffered data



67
68
69
70
71
# File 'lib/experella-proxy.rb', line 67

def self.restart
  opts = @server.options
  stop
  Server.new(opts).run if ExperellaProxy.init(opts)
end

.run(options = {}) ⇒ Object

Creates Server object and calls ExperellaProxy::Server#run if init

Parameters:

  • options (Hash) (defaults to: {})

    Hash passed to the configuration

  • option (Hash)

    a customizable set of options



60
61
62
# File 'lib/experella-proxy.rb', line 60

def self.run(options={})
  @server = Server.new(options).run if ExperellaProxy.init(options)
end

.stopObject

Stops ExperellaProxy



75
76
77
# File 'lib/experella-proxy.rb', line 75

def self.stop
  Proxy.stop
end