Class: HTTP::Request
- Inherits:
-
Object
show all
- Defined in:
- lib/http_client/mri/methods.rb,
lib/http_client/jruby/methods.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(uri, params = {}) ⇒ Request
Returns a new instance of Request.
3
4
5
6
7
|
# File 'lib/http_client/mri/methods.rb', line 3
def initialize(url, params = {})
@requested_uri = url
@params = params
@headers = {}
end
|
Instance Attribute Details
Returns the value of attribute body.
5
6
7
|
# File 'lib/http_client/jruby/methods.rb', line 5
def body
@body
end
|
Returns the value of attribute encoding.
5
6
7
|
# File 'lib/http_client/jruby/methods.rb', line 5
def encoding
@encoding
end
|
Instance Method Details
14
15
16
|
# File 'lib/http_client/mri/methods.rb', line 14
def ()
@headers =
end
|
#basic_auth(username, password) ⇒ Object
9
10
11
12
|
# File 'lib/http_client/mri/methods.rb', line 9
def basic_auth(username, password)
@username = username
@password = password
end
|
#content_type=(type) ⇒ Object
18
19
20
|
# File 'lib/http_client/mri/methods.rb', line 18
def content_type=(content_type)
@content_type = content_type
end
|
#execute_native_request(client) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/http_client/mri/methods.rb', line 26
def execute_native_request(client)
host, port, req = create_request
req.basic_auth(@username, @password)
@headers.each {|name, value| req[name.to_s] = value.to_s}
req.content_type = @content_type unless @content_type.nil?
req.body = @body unless @body.nil?
HTTP::Response.new(client.execute_request(host, port, req))
end
|
#make_native_request(client) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/http_client/jruby/methods.rb', line 34
def make_native_request(client)
request = create_native_request
request.entity = StringEntity.new(@body) unless @body.nil?
@headers.each { |name, value| request.(name.to_s, value.to_s) }
unless @username.nil?
client.credentials_provider.set_credentials(AuthScope::ANY, UsernamePasswordCredentials.new(@username, @password))
end
HTTP::Response.new(client.execute(request), client.cookie_store.cookies)
end
|