Module: CelluloidBenchmark::Visitors::HTTPMethods

Included in:
CelluloidBenchmark::Visitor
Defined in:
lib/celluloid_benchmark/visitors/http_methods.rb

Instance Method Summary collapse

Instance Method Details

#get(uri, parameters = [], referer = nil, headers = {}) ⇒ Object



4
5
6
7
8
# File 'lib/celluloid_benchmark/visitors/http_methods.rb', line 4

def get(uri, parameters = [], referer = nil, headers = {})
  page = browser.get(uri, parameters, referer, headers)
  log_response page
  page
end

#get_json(uri, headers = {}) ⇒ Object



22
23
24
# File 'lib/celluloid_benchmark/visitors/http_methods.rb', line 22

def get_json(uri, headers = {})
  get uri, [], nil, headers.merge("Accept" => "application/json, text/javascript, */*; q=0.01")
end

#post(uri, query = {}, headers = {}) ⇒ Object



10
11
12
13
14
# File 'lib/celluloid_benchmark/visitors/http_methods.rb', line 10

def post(uri, query = {}, headers = {})
  page = browser.post(uri, query, headers)
  log_response page
  page
end

#post_json(uri, query, headers = {}) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/celluloid_benchmark/visitors/http_methods.rb', line 26

def post_json(uri, query, headers = {})
  post(
    uri,
    MultiJson.dump(query),
    { "Content-Type" => "application/json", "Accept" => "application/json, text/javascript, */*; q=0.01" }.merge(headers)
  )
end

#put(uri, entity, headers = {}) ⇒ Object



16
17
18
19
20
# File 'lib/celluloid_benchmark/visitors/http_methods.rb', line 16

def put(uri, entity, headers = {})
  page = browser.put(uri, entity, headers)
  log_response page
  page
end

#put_json(uri, query, headers = {}) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/celluloid_benchmark/visitors/http_methods.rb', line 34

def put_json(uri, query, headers = {})
  put(
    uri,
    MultiJson.dump(query),
    { "Content-Type" => "application/json", "Accept" => "application/json, text/javascript, */*; q=0.01" }.merge(headers)
  )
end