Skip to content

Instantly share code, notes, and snippets.

@yesnik
Created October 21, 2015 12:01
Show Gist options
  • Select an option

  • Save yesnik/9a7b0f8ac5d6b3f2bb91 to your computer and use it in GitHub Desktop.

Select an option

Save yesnik/9a7b0f8ac5d6b3f2bb91 to your computer and use it in GitHub Desktop.

Revisions

  1. yesnik created this gist Oct 21, 2015.
    364 changes: 364 additions & 0 deletions response_example.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,364 @@
    # This is the content of variable request.env
    # We get this content in controller:

    # class BlogsController < ApplicationController
    # def index
    # render plain: "Response: #{ YAML::dump(request.env) }"
    # end
    # end


    '{
    "GATEWAY_INTERFACE"=>"CGI/1.1",
    "PATH_INFO"=>"/blogs",
    "QUERY_STRING"=>"",
    "REMOTE_ADDR"=>"127.0.0.1",
    "REMOTE_HOST"=>"127.0.0.1",
    "REQUEST_METHOD"=>"GET",
    "REQUEST_URI"=>"http://127.0.0.1:3001/blogs/",
    "SCRIPT_NAME"=>"",
    "SERVER_NAME"=>"127.0.0.1",
    "SERVER_PORT"=>"3001",
    "SERVER_PROTOCOL"=>"HTTP/1.1",
    "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/1.9.3/2014-05-14)",
    "HTTP_HOST"=>"127.0.0.1:3001",
    "HTTP_USER_AGENT"=>"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0",
    "HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
    "HTTP_ACCEPT_LANGUAGE"=>"ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
    "HTTP_ACCEPT_ENCODING"=>"gzip, deflate",
    "HTTP_COOKIE"=>"_ga=GA1.1.1557941356.1442820961; _blog_session=RnRETUplQke4156648557d354066caa1222",
    "HTTP_CONNECTION"=>"keep-alive",
    "HTTP_IF_NONE_MATCH"=>"\"030711d01a00ffb62231bc68e8f8936d\"",
    "HTTP_CACHE_CONTROL"=>"max-age=0",
    "rack.version"=>[1, 2],
    "rack.input"=>#<StringIO:0x000000060974b8>,
    "rack.errors"=>#<IO:<STDERR>>,
    "rack.multithread"=>false,
    "rack.multiprocess"=>false,
    "rack.run_once"=>false,
    "rack.url_scheme"=>"http",
    "HTTP_VERSION"=>"HTTP/1.1",
    "REQUEST_PATH"=>"/blogs/",
    "ORIGINAL_FULLPATH"=>"/blogs/",
    "ORIGINAL_SCRIPT_NAME"=>"",
    "action_dispatch.routes"=>#<ActionDispatch::Routing::RouteSet:0x000000054f2900>,
    "action_dispatch.parameter_filter"=>[:password],
    "action_dispatch.redirect_filter"=>[],
    "action_dispatch.secret_token"=>nil,
    "action_dispatch.secret_key_base"=>"12b27c22199ab60bb9256d44a0277",
    "action_dispatch.show_exceptions"=>true,
    "action_dispatch.show_detailed_exceptions"=>true,
    "action_dispatch.logger"=>#<ActiveSupport::Logger:0x0000000502ffd0
    @progname=nil, @level=0,
    @default_formatter=#<Logger::Formatter:0x00000005038540 @datetime_format=nil>,
    @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x00000005482420 @datetime_format=nil>,
    @logdev=#<Logger::LogDevice:0x00000005038450
    @shift_size=nil, @shift_age=nil, @filename=nil,
    @dev=#<File:/home/yesnik/learn/rails_projects/blog/log/development.log>,
    @mutex=#<Logger::LogDevice::LogDeviceMutex:0x00000005038428
    @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x000000050382c0>
    >
    >
    >,
    "action_dispatch.backtrace_cleaner"=>#<Rails::BacktraceCleaner:0x00000005580a70
    @filters=[
    #<Proc:0x00000005580908@/home/yesnik/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.8/lib/rails/backtrace_cleaner.rb:10>,
    #<Proc:0x000000055807c8@/home/yesnik/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.8/lib/rails/backtrace_cleaner.rb:11>,
    #<Proc:0x000000055804a8@/home/yesnik/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.8/lib/rails/backtrace_cleaner.rb:12>,
    #<Proc:0x0000000557f1c0@/home/yesnik/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.8/lib/rails/backtrace_cleaner.rb:24>
    ],
    @silencers=[
    #<Proc:0x0000000557ef90@/home/yesnik/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.8/lib/rails/backtrace_cleaner.rb:15>
    ]
    >,
    "action_dispatch.key_generator"=>#<ActiveSupport::CachingKeyGenerator:0x0000000557e9c8
    @key_generator=#<ActiveSupport::KeyGenerator:0x0000000557ea40
    @secret="12b27c22199a3e28c8268bb0044b60bb9256d44a0277",
    @iterations=1000
    >,
    @cache_keys=#<ThreadSafe::Cache:0x0000000557e900
    @backend={
    "encrypted cookie64"=>"O\xFE,A\"\xBA.X\x82\x95\xB7\xB8T\xB8\xDE\xE9\xAC1\xEE",
    "signed encrypted cookie64"=>"\x01\x89k\x81Z>\x11\x03iY\x82\xF3\xBEK)\xCE\xE5\xFA,\xBC\x83",
    "signed cookie64"=>"\x9A@\xCBp*+\x86%\x81\xB18f\xE2gb\x86\x8A\x96\xDA2s\x03\xE2?\x91\xE5{A\xFDP\x9D\xFCE"
    },
    @default_proc=nil
    >
    >,
    "action_dispatch.http_auth_salt"=>"http authentication",
    "action_dispatch.signed_cookie_salt"=>"signed cookie",
    "action_dispatch.encrypted_cookie_salt"=>"encrypted cookie",
    "action_dispatch.encrypted_signed_cookie_salt"=>"signed encrypted cookie",
    "action_dispatch.cookies_serializer"=>:json,
    "ROUTES_44536960_SCRIPT_NAME"=>"",
    "action_dispatch.request_id"=>"635d6fb7-3aac-4fce-9ed9-f6f1ccce9bae",
    "action_dispatch.remote_ip"=>127.0.0.1,
    "rack.session"=>#<ActionDispatch::Request::Session:0x00000006f30c40
    @by=#<ActionDispatch::Session::CookieStore:0x000000054979d8
    @app=#<ActionDispatch::Flash:0x00000005497bb8
    @app=#<ActionDispatch::ParamsParser:0x00000005497d70
    @app=#<Rack::Head:0x00000005497eb0
    @app=#<Rack::ConditionalGet:0x00000005498cc0
    @app=#<Rack::ETag:0x00000005498e50
    @app=#<Warden::Manager:0x00000005499b98
    @config={
    :default_scope=>:user, :scope_defaults=>{},
    :default_strategies=>{:user=>[:rememberable, :database_authenticatable]},
    :intercept_401=>false,
    :failure_app=>#<Devise::Delegator:0x00000006edad40>
    },
    @app=#<ActionDispatch::Routing::RouteSet:0x000000054f2900>
    >,
    @cache_control="max-age=0, private, must-revalidate",
    @no_cache_control="no-cache"
    >
    >
    >,
    @parsers={application/json=>:json}
    >
    >,
    @default_options={:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false},
    @key="_blog_session",
    @cookie_only=true
    >,
    @env={...},
    @delegate={
    "session_id"=>"d905e16e63ab179d417ba7fd9cccdd94",
    "_csrf_token"=>"fbaiiKtXmOt36dWNSNeupeXHoVaWtKnqR/9OOg0xfi4="
    },
    @loaded=true,
    @exists=true
    >,
    "rack.session.options"=>#<ActionDispatch::Request::Session::Options:0x00000006f30ba0
    @by=#<ActionDispatch::Session::CookieStore:0x000000054979d8
    @app=#<ActionDispatch::Flash:0x00000005497bb8
    @app=#<ActionDispatch::ParamsParser:0x00000005497d70
    @app=#<Rack::Head:0x00000005497eb0
    @app=#<Rack::ConditionalGet:0x00000005498cc0
    @app=#<Rack::ETag:0x00000005498e50
    @app=#<Warden::Manager:0x00000005499b98
    @config={
    :default_scope=>:user,
    :scope_defaults=>{},
    :default_strategies=>{:user=>[:rememberable, :database_authenticatable]},
    :intercept_401=>false,
    :failure_app=>#<Devise::Delegator:0x00000006edad40>
    },
    @app=#<ActionDispatch::Routing::RouteSet:0x000000054f2900>
    >,
    @cache_control="max-age=0, private, must-revalidate",
    @no_cache_control="no-cache"
    >
    >
    >,
    @parsers={application/json=>:json}
    >
    >,
    @default_options={:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false},
    @key="_blog_session",
    @cookie_only=true
    >,
    @env={...},
    @delegate={
    :path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false,
    :id=>"d905e16e63ab179d417ba7fd9cccdd94"
    }
    >,
    "warden"=>Warden::Proxy:58295580
    @config={
    :default_scope=>:user,
    :scope_defaults=>{},
    :default_strategies=>{:user=>[:rememberable, :database_authenticatable]},
    :intercept_401=>false,
    :failure_app=>#<Devise::Delegator:0x00000006edad40>
    },
    "action_dispatch.request.path_parameters"=>{ :action=>"index", :controller=>"blogs" },
    "action_controller.instance"=>#<BlogsController:0x000000070687c0
    @_action_has_layout=true,
    @_routes=nil,
    @_headers={"Content-Type"=>"text/html"},
    @_status=200,
    @_request=#<ActionDispatch::Request:0x00000007068658
    @env={...},
    @symbolized_path_params=nil,
    @filtered_parameters={
    "action"=>"index",
    "controller"=>"blogs"
    },
    @filtered_env=nil,
    @filtered_path=nil,
    @protocol=nil,
    @port=nil,
    @method="GET",
    @request_method="GET",
    @remote_ip=nil,
    @original_fullpath=nil,
    @fullpath="/blogs",
    @ip=nil,
    @uuid=nil
    >,
    @_response=#<ActionDispatch::Response:0x00000007068630
    @mon_owner=nil,
    @mon_count=0,
    @mon_mutex=#<Mutex:0x00000007068590>,
    @stream=#<ActionDispatch::Response::Buffer:0x00000007068518
    @response=#<ActionDispatch::Response:0x00000007068630 ...>,
    @buf=[],
    @closed=false
    >,
    @header={"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "X-Content-Type-Options"=>"nosniff"},
    @status=200, @sending_file=false,
    @blank=false,
    @cv=#<MonitorMixin::ConditionVariable:0x000000070684f0
    @monitor=#<ActionDispatch::Response:0x00000007068630 ...>,
    @cond=#<ConditionVariable:0x000000070684c8
    @waiters=[],
    @waiters_mutex=#<Mutex:0x00000007068478>
    >
    >,
    @committed=false, @sending=false, @sent=false, @content_type=nil, @charset=nil, @cache_control={}, @etag=nil,
    @request=#<ActionDispatch::Request:0x00000007068658
    @env={...},
    @symbolized_path_params=nil,
    @filtered_parameters={
    "action"=>"index",
    "controller"=>"blogs"
    },
    @filtered_env=nil, @filtered_path=nil, @protocol=nil,
    @port=nil,
    @method="GET", @request_method="GET", @remote_ip=nil, @original_fullpath=nil,
    @fullpath="/blogs", @ip=nil, @uuid=nil
    >
    >,
    @_env={...}, @_prefixes=["blogs", "application"],
    @_lookup_context=#<ActionView::LookupContext:0x00000007068158
    @details_key=nil,
    @details={
    :locale=>[:en],
    :formats=>[:html],
    :variants=>[],
    :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]
    },
    @skip_default_locale=false, @cache=true,
    @prefixes=["blogs", "application"],
    @rendered_format=nil,
    @view_paths=#<ActionView::PathSet:0x000000070680e0
    @paths=[
    /home/yesnik/learn/rails_projects/blog/app/views,
    /home/yesnik/.rvm/gems/ruby-1.9.3-p547/gems/twitter-bootstrap-rails-3.2.0/app/views,
    /home/yesnik/.rvm/gems/ruby-1.9.3-p547/gems/devise-3.4.1/app/views
    ]
    >
    >,
    @_action_name="index",
    @_response_body=nil,
    @marked_for_same_origin_verification=true,
    @_config={}
    >,
    "action_dispatch.request.content_type"=>nil,
    "action_dispatch.request.request_parameters"=>{},
    "rack.request.query_string"=>"",
    "rack.request.query_hash"=>{},
    "action_dispatch.request.query_parameters"=>{},
    "action_dispatch.request.parameters"=>{
    "action"=>"index",
    "controller"=>"blogs"
    },
    "action_dispatch.request.formats"=>[text/html],
    "rack.request.cookie_hash"=>{
    "_ga"=>"GA1.1.1557941356.1442820961",
    "_blog_session"=>"RnRETUplQkVuOU9lanNnZHZ066caa1222"
    },
    "rack.request.cookie_string"=>"_ga=GA1.1.1557941356.1442820961; _blog_session=RnRETUplQkV4066caa1222",
    "action_dispatch.cookies"=>#<ActionDispatch::Cookies::CookieJar:0x00000007078620
    @key_generator=#<ActiveSupport::CachingKeyGenerator:0x0000000557e9c8
    @key_generator=#<ActiveSupport::KeyGenerator:0x0000000557ea40
    @secret="12b27c22199a3e28c8268bb009256d44a0277",
    @iterations=1000
    >,
    @cache_keys=#<ThreadSafe::Cache:0x0000000557e900
    @backend={
    "encrypted cookie64"=>"O\xFE,A\"\xBA.X\x82\x95\xB7\xB8T\x94<\xB8\xDE\xE9\xAC1\xEE",
    "signed encrypted cookie64"=>"\x01\x89k\x81Z>\x11\x03iY\x82\xF6\xF1\xCC\xB7\xFA,\xBC\x83",
    "signed cookie64"=>"\x9A@\xCBp*+\x86%\x81\xB18f\xE2gb\xC7\xA4V\v>\xE5{A\xFDP\x9D\xFCE"
    },
    @default_proc=nil
    >
    >,
    @set_cookies={},
    @delete_cookies={},
    @host="127.0.0.1",
    @secure=false,
    @options={
    :signed_cookie_salt=>"signed cookie",
    :encrypted_cookie_salt=>"encrypted cookie",
    :encrypted_signed_cookie_salt=>"signed encrypted cookie",
    :secret_token=>nil,
    :secret_key_base=>"12b27c22199a3e28c8f472854b60bb9256d44a0277",
    :upgrade_legacy_signed_cookies=>false,
    :serializer=>:json
    },
    @cookies={
    "_ga"=>"GA1.1.1557941356.1442820961",
    "_blog_session"=>"RnRETUplQkVu9529a6850ae4156648557d354066caa1222"
    },
    @committed=false,
    @encrypted=#<ActionDispatch::Cookies::EncryptedCookieJar:0x000000070776d0
    @parent_jar=#<ActionDispatch::Cookies::CookieJar:0x00000007078620 ...>,
    @options={
    :signed_cookie_salt=>"signed cookie",
    :encrypted_cookie_salt=>"encrypted cookie",
    :encrypted_signed_cookie_salt=>"signed encrypted cookie",
    :secret_token=>nil,
    :secret_key_base=>"12b27c22199a3e28c826872854b60bb9256d44a0277",
    :upgrade_legacy_signed_cookies=>false,
    :serializer=>:json
    },
    @encryptor=#<ActiveSupport::MessageEncryptor:0x00000007077450
    @secret="O\xFE,A\"\xBA.X\x82\x95\xAD\x97G[\xBC\x03\x9E\x1E;h\x94<\xB8\xDE\xE9\xAC1\xEE",
    @sign_secret="\x01\x89k\x81Z>\x11\x03iY\x82\xD1*\xAB\x97\x96\r\x7F\xF6\xF1\xCC\xB7\xFA,\xBC\x83",
    @cipher="aes-256-cbc",
    @verifier=#<ActiveSupport::MessageVerifier:0x000000070773b0
    @secret="\x01\x89k\x81Z>\x11\x03iY\x82\xD1*\xAB\x97\x96\r\x7F\xF6\xF1\xCC\xB7\xFA,\xBC\x83",
    @digest="SHA1",
    @serializer=ActiveSupport::MessageEncryptor::NullSerializer
    >,
    @serializer=ActionDispatch::Cookies::NullSerializer
    >
    >,
    @signed_or_encrypted=#<ActionDispatch::Cookies::EncryptedCookieJar:0x000000070776d0
    @parent_jar=#<ActionDispatch::Cookies::CookieJar:0x00000007078620 ...>,
    @options={
    :signed_cookie_salt=>"signed cookie",
    :encrypted_cookie_salt=>"encrypted cookie",
    :encrypted_signed_cookie_salt=>"signed encrypted cookie",
    :secret_token=>nil,
    :secret_key_base=>"12b27c22199a3e28c829bd8f472854b60bb9256d44a0277",
    :upgrade_legacy_signed_cookies=>false,
    :serializer=>:json
    },
    @encryptor=#<ActiveSupport::MessageEncryptor:0x00000007077450
    @secret="O\xFE,A\"\xBA.X\x82\x95\xB7\xB8T\x03\x9E\x1E;h\x94<\xB8\xDE\xE9\xAC1\xEE",
    @sign_secret="\x01\x89k\x81Z>\x11\x03iY\x82\xF3\x96\r\x7F\xF6\xF1\xCC\xB7\xFA,\xBC\x83",
    @cipher="aes-256-cbc",
    @verifier=#<ActiveSupport::MessageVerifier:0x000000070773b0
    @secret="\x01\x89k\x81Z>\x11\x03iY\x82\x99g\xD1*\xAB\x97\x96\r\x7F\xF6\xF1\xCC\xB7\xFA,\xBC\x83",
    @digest="SHA1",
    @serializer=ActiveSupport::MessageEncryptor::NullSerializer
    >,
    @serializer=ActionDispatch::Cookies::NullSerializer
    >
    >
    >,
    "action_dispatch.request.unsigned_session_cookie"=>{
    "session_id"=>"d905e16e63ab179d417ba7fd9cccdd94",
    "_csrf_token"=>"fbaiiKtXmOt36dWNSNeupeXHoVaWtKnqR/9OOg0xfi4="
    }
    }'