Sha256: f688bf4d2af6ad119536f70bfcc32cdc1e7a0aee21aa5cc45aecc9eff4b61db0

Contents?: true

Size: 1.04 KB

Versions: 15

Compression:

Stored size: 1.04 KB

Contents

require 'sitehub/request'
require 'sitehub/request_mapping'
require 'sitehub/rules'
require 'sitehub/resolver'
require 'faraday'
require 'sitehub/constants'

# Requirements: https://www.mnot.net/blog/2011/07/11/what_proxies_must_do
# 1. remove hop by hop headers
# 2. detect bad framing: where content length and content-encoding clash or are incorrect
# 3. fix conflicts between header and URL header
# 4. insert via (optional)
# 5. Expect header (optional)

class SiteHub
  class DownstreamClient
    include Constants

    attr_reader :http_client

    def initialize
      @http_client = Faraday.new(ssl: { verify: false }) do |con|
        con.adapter :em_synchrony
      end
    end

    def call(sitehub_request)
      response = http_client.send(sitehub_request.request_method, sitehub_request.uri) do |request|
        request.headers = sitehub_request.headers
        request.body = sitehub_request.body
        request.params = sitehub_request.params
      end

      Rack::Response.new(response.body, response.status, response.headers)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
sitehub-0.5.0.alpha12 lib/sitehub/downstream_client.rb
sitehub-0.4.10 lib/sitehub/downstream_client.rb
sitehub-0.5.0.alpha11 lib/sitehub/downstream_client.rb
sitehub-0.5.0.alpha10 lib/sitehub/downstream_client.rb
sitehub-0.5.0.alpha8 lib/sitehub/downstream_client.rb
sitehub-0.5.0.alpha7 lib/sitehub/downstream_client.rb
sitehub-0.5.0.alpha6 lib/sitehub/downstream_client.rb
sitehub-0.5.0.alpha5 lib/sitehub/downstream_client.rb
sitehub-0.5.0.alpha4 lib/sitehub/downstream_client.rb
sitehub-0.5.0.alpha3 lib/sitehub/downstream_client.rb
sitehub-0.5.0.alpha2 lib/sitehub/downstream_client.rb
sitehub-0.4.9 lib/sitehub/downstream_client.rb
sitehub-0.4.8 lib/sitehub/downstream_client.rb
sitehub-0.4.7 lib/sitehub/downstream_client.rb
sitehub-0.4.6 lib/sitehub/downstream_client.rb