Class: Net::HTTPGenericRequest
- Inherits:
-
Object
- Object
- Net::HTTPGenericRequest
- Includes:
- HTTPHeader
- Defined in:
- lib/jnlp/jnlp.rb
Overview
Monkey patch Net::HTTP so it always provides a User-Agent if the request doesn’t already specify one.
This compensates for a bug in Tomcat/webstart servers which throw a 500 error for requests w/o a User-Agent header.
Instance Method Summary collapse
-
#initialize(m, reqbody, resbody, path, initheader = nil) ⇒ HTTPGenericRequest
constructor
A new instance of HTTPGenericRequest.
Constructor Details
#initialize(m, reqbody, resbody, path, initheader = nil) ⇒ HTTPGenericRequest
Returns a new instance of HTTPGenericRequest.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jnlp/jnlp.rb', line 25 def initialize(m, reqbody, resbody, path, initheader = nil) @method = m @request_has_body = reqbody @response_has_body = resbody raise ArgumentError, "HTTP request path is empty" if path.empty? @path = path initialize_http_header initheader self['Accept'] ||= '*/*' self['User-Agent'] ||= 'Ruby' # this is the new line @body = nil @body_stream = nil end |