Class: BitGirder::Http::HttpResponse
- Inherits:
-
BitGirderClass
- Object
- BitGirderClass
- BitGirder::Http::HttpResponse
- Defined in:
- lib/bitgirder/http.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_mingle_struct(ms) ⇒ Object
242 243 244 245 246 247 248 249 250 251 |
# File 'lib/bitgirder/http.rb', line 242 def self.from_mingle_struct( ms ) stat, hdrs, body = ms[ :status ], ms[ :headers ], ms[ :body ] self.new( :status => stat ? HttpStatus.from_mingle_struct( stat ) : nil, :headers => hdrs ? HttpHeaders.from_mingle_struct( hdrs ) : nil, :body => body ? body.buf : nil ) end |
.from_net_http_response(resp, opts = {}) ⇒ Object
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/bitgirder/http.rb', line 207 def self.from_net_http_response( resp, opts = {} ) not_nil( resp, :resp ) not_nil( opts, :opts ) log_body = opts[ :log_body ] attrs = { :status => HttpStatus.as_instance( resp ), :headers => HttpHeaders.as_instance( resp ) } if opts[ :log_body ] && resp.class.body_permitted? attrs[ :body ] = resp.body end new( attrs ) end |
Instance Method Details
#to_mingle_struct ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/bitgirder/http.rb', line 230 def to_mingle_struct MingleStruct.new( :type => :"bitgirder:http@v1/HttpResponse", :fields => { :status => @status ? @status.to_mingle_struct : nil, :headers => @headers ? @headers.to_mingle_struct : nil, :body => @body ? MingleBuffer.new( body ) : nil } ) end |