Class: Strawman::HttpRequest

Inherits:
Object
  • Object
show all
Includes:
EventMachine::Deferrable
Defined in:
lib/strawman/http_request.rb

Overview

HttpRequest

A simple wrapper for em-http-client’s HttpRequest.

Instance Method Summary collapse

Constructor Details

#initialize(proxy_list, url) ⇒ HttpRequest

Returns a new instance of HttpRequest.



9
10
11
12
13
14
15
16
# File 'lib/strawman/http_request.rb', line 9

def initialize(proxy_list, url)
  proxy_response = proxy_list.proxy
  proxy_response.callback do |proxy|
    @proxy = proxy
    @request = Transport.new(@proxy.proxy_url(url))
    succeed
  end
end

Instance Method Details

#deleteObject

Can’t and won’t be implemented due to Glype not proxying these requests.

Raises:

  • (NotImplementedError)


61
62
63
# File 'lib/strawman/http_request.rb', line 61

def delete
  raise NotImplementedError
end

#get(opts = {}) ⇒ Object

Handles HTTP GET requests. Query parameters should be specified on the url given to HttpRequest.

  • opts: Takes a hash of options identical to EventMachine::HttpRequest.

NOTE: most options will be ignored, except body data and proxy information.



27
28
29
30
31
32
# File 'lib/strawman/http_request.rb', line 27

def get(opts={})
  opts = merge_referer_into_opts(opts)
  http = @request.get opts
  http.callback { munge_output }
  http
end

#headObject

Can’t and won’t be implemented due to Glype not proxying these requests.

Raises:

  • (NotImplementedError)


68
69
70
# File 'lib/strawman/http_request.rb', line 68

def head
  raise NotImplementedError
end

#post(opts = {}) ⇒ Object

Handles HTTP POST requests. In for the post request to be a sent as a POST request, atleast one POST field must be specified in the opts. Query parameters should be specified on the url given to HttpRequest.

  • opts: Takes a hash of options identical to EventMachine::HttpRequest.

NOTE: most options will be ignored, except body data and proxy information.



44
45
46
47
48
49
# File 'lib/strawman/http_request.rb', line 44

def post(opts={})
  opts = merge_referer_into_opts(opts)
  http = @request.post opts
  http.callback { munge_output }
  http
end

#putObject

Can’t and won’t be implemented due to Glype not proxying these requests.

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/strawman/http_request.rb', line 54

def put
  raise NotImplementedError
end