9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/hbserver/server.rb', line 9
def call env
request = Rack::Request.new env
response = Rack::Response.new
_path_info = request.path_info _params = request.params _request_method = request.request_method
_body = {
ip: request.ip,
cookies: request.cookies,
session: request.session,
session_options: request.session_options,
referer: request.referer,
user_agent: request.user_agent,
method: request.request_method,
path: request.path,
path_info: request.path_info,
params: request.params,
port: request.port,
url: request.url,
base_url: request.base_url,
fullpath: request.fullpath,
host: request.host,
host_with_port: request.host_with_port,
logger: request.logger,
media_type: request.media_type,
media_type_params: request.media_type_params,
POST: request.POST,
query_string: request.query_string,
scheme: request.scheme,
script_name: request.script_name,
ssl: request.ssl?,
trace: request.trace?,
xhr: request.xhr?,
client: request['client']
}.to_json
if _path_info == "/baidu"
response.redirect('http://baidu.com')
else
response.write _body
response.["Content-Length"] = _body.to_s.bytesize.to_s
response.['Transfer-Encoding'] = 'chunked'
response.["Content-Type"] = "application/json"
response.status = 200
end
response.finish
end
|