Class: Yajl::HttpStream
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: HttpError, InvalidContentType
Constant Summary
- 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)
-
+ (Object) delete(uri, opts = {}, &block)
Makes a basic HTTP DELETE request to the URI provided.
-
+ (Object) get(uri, opts = {}, &block)
Makes a basic HTTP GET request to the URI provided.
-
+ (Object) post(uri, body, opts = {}, &block)
Makes a basic HTTP POST request to the URI provided.
-
+ (Object) put(uri, body, opts = {}, &block)
Makes a basic HTTP PUT request to the URI provided.
Instance Method Summary (collapse)
-
- (Object) delete(uri, opts = {}, &block)
Makes a basic HTTP DELETE request to the URI provided allowing the user to terminate the connection.
-
- (Object) get(uri, opts = {}, &block)
Makes a basic HTTP GET request to the URI provided allowing the user to terminate the connection.
-
- (Object) post(uri, body, opts = {}, &block)
Makes a basic HTTP POST request to the URI provided allowing the user to terminate the connection.
-
- (Object) put(uri, body, opts = {}, &block)
Makes a basic HTTP PUT request to the URI provided allowing the user to terminate the connection.
-
- (Object) terminate
Terminate a running HTTPStream instance.
Class Method Details
+ (Object) delete(uri, opts = {}, &block)
Makes a basic HTTP DELETE request to the URI provided
69 70 71 |
# File 'lib/yajl/http_stream.rb', line 69 def self.delete(uri, opts = {}, &block) request("DELETE", uri, opts, &block) end |
+ (Object) get(uri, opts = {}, &block)
Makes a basic HTTP GET request to the URI provided
30 31 32 |
# File 'lib/yajl/http_stream.rb', line 30 def self.get(uri, opts = {}, &block) request("GET", uri, opts, &block) end |
+ (Object) post(uri, body, opts = {}, &block)
Makes a basic HTTP POST request to the URI provided
43 44 45 |
# File 'lib/yajl/http_stream.rb', line 43 def self.post(uri, body, opts = {}, &block) request("POST", uri, opts.merge({:body => body}), &block) end |
+ (Object) put(uri, body, opts = {}, &block)
Makes a basic HTTP PUT request to the URI provided
56 57 58 |
# File 'lib/yajl/http_stream.rb', line 56 def self.put(uri, body, opts = {}, &block) request("PUT", uri, opts.merge({:body => body}), &block) end |
Instance Method Details
- (Object) delete(uri, opts = {}, &block)
Makes a basic HTTP DELETE request to the URI provided allowing the user to terminate the connection
74 75 76 77 78 79 |
# File 'lib/yajl/http_stream.rb', line 74 def delete(uri, opts = {}, &block) initialize_socket(uri, opts) HttpStream::delete(uri, opts, &block) rescue IOError => e raise e unless @intentional_termination end |
- (Object) get(uri, opts = {}, &block)
Makes a basic HTTP GET request to the URI provided allowing the user to terminate the connection
35 36 37 38 39 40 |
# File 'lib/yajl/http_stream.rb', line 35 def get(uri, opts = {}, &block) initialize_socket(uri, opts) HttpStream::get(uri, opts, &block) rescue IOError => e raise e unless @intentional_termination end |
- (Object) post(uri, body, opts = {}, &block)
Makes a basic HTTP POST request to the URI provided allowing the user to terminate the connection
48 49 50 51 52 53 |
# File 'lib/yajl/http_stream.rb', line 48 def post(uri, body, opts = {}, &block) initialize_socket(uri, opts) HttpStream::post(uri, body, opts, &block) rescue IOError => e raise e unless @intentional_termination end |
- (Object) put(uri, body, opts = {}, &block)
Makes a basic HTTP PUT request to the URI provided allowing the user to terminate the connection
61 62 63 64 65 66 |
# File 'lib/yajl/http_stream.rb', line 61 def put(uri, body, opts = {}, &block) initialize_socket(uri, opts) HttpStream::put(uri, body, opts, &block) rescue IOError => e raise e unless @intentional_termination end |
- (Object) terminate
Terminate a running HTTPStream instance
82 83 84 85 |
# File 'lib/yajl/http_stream.rb', line 82 def terminate @intentional_termination = true @socket.close end |