Class: Xplenty::Kensa::PostProxy

Inherits:
WEBrick::HTTPServer
  • Object
show all
Defined in:
lib/xplenty/kensa/post_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(sso) ⇒ PostProxy

Returns a new instance of PostProxy.



4
5
6
7
8
9
# File 'lib/xplenty/kensa/post_proxy.rb', line 4

def initialize(sso)
  @params = sso.query_params
  @sso = sso
  super :Port => sso.proxy_port, :AccessLog => WEBrick::Log.new(StringIO.new),
          :Logger => WEBrick::Log.new(StringIO.new)
end

Instance Method Details

#service(req, res) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/xplenty/kensa/post_proxy.rb', line 11

def service(req, res)
  res.status = 200
  res.body = <<-HTML
    <html>
      <head>
        <script type="text/javascript">
          window.onload = function() { document.forms[0].submit() }
        </script>
      </head>
      <body>
        <form action="#{@sso.post_url}" method="POST">
          #{ @params.map do |key, value|
              %|<input type="hidden" name="#{key}" value="#{value}" />|
             end.join("\n")  
           }
        </form>
      </body>
    </html>
  HTML
  res["Content-Length"] = res.body.size
  @status = :Shutdown
end