Class: Yajl::HttpStream

Inherits:
Object show all
Defined in:
lib/yajl/http_stream.rb

Overview

This module is for making HTTP requests to which the response bodies (and possibly requests in the near future) are streamed directly into Yajl.

Defined Under Namespace

Classes: InvalidContentType

Constant Summary collapse

ALLOWED_MIME_TYPES =

The mime-type we expect the response to be. If it’s anything else, we can’t parse it and an InvalidContentType is raised.

["application/json", "text/plain"]

Class Method Summary collapse

Class Method Details

.delete(uri, opts = {}, &block) ⇒ Object

Makes a basic HTTP DELETE request to the URI provided



35
36
37
# File 'lib/yajl/http_stream.rb', line 35

def self.delete(uri, opts = {}, &block)
  request("DELETE", uri, opts, &block)
end

.get(uri, opts = {}, &block) ⇒ Object

Makes a basic HTTP GET request to the URI provided



20
21
22
# File 'lib/yajl/http_stream.rb', line 20

def self.get(uri, opts = {}, &block)
  request("GET", uri, opts, &block)
end

.post(uri, body, opts = {}, &block) ⇒ Object

Makes a basic HTTP POST request to the URI provided



25
26
27
# File 'lib/yajl/http_stream.rb', line 25

def self.post(uri, body, opts = {}, &block)
  request("POST", uri, opts.merge({:body => body}), &block)
end

.put(uri, body, opts = {}, &block) ⇒ Object

Makes a basic HTTP PUT request to the URI provided



30
31
32
# File 'lib/yajl/http_stream.rb', line 30

def self.put(uri, body, opts = {}, &block)
  request("PUT", uri, opts.merge({:body => body}), &block)
end

.terminate(thread) ⇒ Object

Terminate a running HTTPStream instance given the thread it’s running in



40
41
42
43
# File 'lib/yajl/http_stream.rb', line 40

def self.terminate(thread)
  thread[:yajl_intentional_termination] = true
  thread[:yajl_socket].close
end