Class: Watobo::Request
Constant Summary
Constants included
from Diff::LCS
Diff::LCS::BalancedCallbacks, Diff::LCS::PATCH_MAP, Diff::LCS::SequenceCallbacks, Diff::LCS::VERSION
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#xml
#cookies
Methods included from Diff::LCS
LCS, __diff_direction, __inverse_vector, __lcs, __normalize_patchset, __position_hash, __replace_next_larger, diff, #diff, #lcs, patch, #patch, #patch!, patch!, sdiff, #sdiff, traverse_balanced, #traverse_balanced, traverse_sequences, #traverse_sequences, #unpatch, #unpatch!, unpatch!
Constructor Details
#initialize(r) ⇒ Request
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/watobo/core/request.rb', line 112
def initialize(r)
if r.respond_to? :concat
self.concat r
elsif r.is_a? String
if r =~ /^http/
uri = URI.parse r
self << "GET #{uri.to_s} HTTP/1.1\r\n"
self << "Host: #{uri.host}\r\n"
else
r.extend Watobo::Mixins::RequestParser
self.concat r.to_request
end
end
self.extend Watobo::Mixin::Parser::Url
self.extend Watobo::Mixin::Parser::Web10
self.extend Watobo::Mixin::Shaper::Web10
self.extend Watobo::Mixin::Shaper::HttpResponse
@url = Watobo::HTTP::Url.new(self)
ct = content_type
if ct =~ /\+zlib/
dec_body = Zlib.inflate body
setData dec_body
set_content_type content_type.gsub(/\+zlib/, '')
fix_content_length
end
case self.content_type
when /www-form/i
@data = Watobo::HTTPData::WWW_Form.new(self)
when /application\/json/i
@json = Watobo::HTTPData::JSONData.new(self)
else
@data = Watobo::HTTPData::WWW_Form.new(self)
end
@cookies = Watobo::HTTP::Cookies.new(self)
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
21
22
23
|
# File 'lib/watobo/core/request.rb', line 21
def data
@data
end
|
Returns the value of attribute header.
23
24
25
|
# File 'lib/watobo/core/request.rb', line 23
def
end
|
#url ⇒ Object
Returns the value of attribute url.
22
23
24
|
# File 'lib/watobo/core/request.rb', line 22
def url
@url
end
|
Class Method Details
.create(request) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/watobo/core/request.rb', line 29
def self.create request
request.extend Watobo::Mixin::Parser::Url
request.extend Watobo::Mixin::Parser::Web10
request.extend Watobo::Mixin::Shaper::Web10
end
|
Instance Method Details
#copy ⇒ Object
36
37
38
39
|
# File 'lib/watobo/core/request.rb', line 36
def copy
c = Watobo::Utils.copyObject self
Watobo::Request.new c
end
|
#parameters(*locations, &block) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/watobo/core/request.rb', line 65
def parameters(*locations, &block)
param_locations = [:url, :data, :wwwform, :xml, :cookies, :json]
unless locations.empty?
param_locations.select! { |loc| locations.include? loc }
end
parms = []
parms.concat @url.parameters if param_locations.include?(:url)
parms.concat cookies.parameters if param_locations.include?(:cookies)
parms.concat @data.parameters if !@data.nil? and self.is_wwwform? and (param_locations.include?(:data) or param_locations.include?(:wwwform))
parms.concat @json.parameters if !@json.nil? and self.is_json? and (param_locations.include?(:data) or param_locations.include?(:json))
parms.concat xml.parameters if self.is_xml? and param_locations.include?(:xml)
if block_given?
parms.each do |p|
yield p
end
end
parms
end
|
#set(parm) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/watobo/core/request.rb', line 86
def set(parm)
case parm.location
when :data
@data.set parm
when :url
@url.set parm
when :xml
xml.set parm
when :cookie
cookies.set parm
when :json
@json.set parm
end
true
end
|
#to_s ⇒ Object
104
105
106
107
108
109
110
|
# File 'lib/watobo/core/request.rb', line 104
def to_s
data = self.join
unless has_body?
data << "\r\n" unless data =~ /\r\n\r\n$/
end
data
end
|
#uniq_hash ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/watobo/core/request.rb', line 41
def uniq_hash()
begin
settings = Watobo::Conf::Scanner.to_h
hashbase = site + method + path
get_parm_names.sort.each do |p|
hashbase << p
hashbase << get_parm_value(p) if settings[:non_unique_parms].include?(p)
end
post_parm_names.sort.each do |p|
hashbase << p
hashbase << post_parm_value(p) if settings[:non_unique_parms].include?(p)
end
return Digest::MD5.hexdigest(hashbase)
rescue => bang
puts bang
puts bang.backtrace if $DEBUG
return nil
end
end
|