| Class | Net::HTTPGenericRequest |
| In: |
lib/net/http.rb
|
| Parent: | Object |
Parent of HTTPRequest class. Do not use this directly; use a subclass of HTTPRequest.
Mixes in the HTTPHeader module.
| body | [R] | |
| body_stream | [R] | |
| method | [R] | |
| path | [R] |
# File lib/net/http.rb, line 1466
1466: def initialize(m, reqbody, resbody, path, initheader = nil)
1467: @method = m
1468: @request_has_body = reqbody
1469: @response_has_body = resbody
1470: raise ArgumentError, "HTTP request path is empty" if path.empty?
1471: @path = path
1472: initialize_http_header initheader
1473: self['Accept'] ||= '*/*'
1474: @body = nil
1475: @body_stream = nil
1476: end
# File lib/net/http.rb, line 1500
1500: def body=(str)
1501: @body = str
1502: @body_stream = nil
1503: str
1504: end
# File lib/net/http.rb, line 1493
1493: def body_exist?
1494: warn "Net::HTTPRequest#body_exist? is obsolete; use response_body_permitted?" if $VERBOSE
1495: response_body_permitted?
1496: end
# File lib/net/http.rb, line 1508
1508: def body_stream=(input)
1509: @body = nil
1510: @body_stream = input
1511: input
1512: end
# File lib/net/http.rb, line 1485
1485: def request_body_permitted?
1486: @request_has_body
1487: end
# File lib/net/http.rb, line 1489
1489: def response_body_permitted?
1490: @response_has_body
1491: end
# File lib/net/http.rb, line 1535
1535: def send_request_with_body(sock, ver, path, body)
1536: self.content_length = body.length
1537: delete 'Transfer-Encoding'
1538: supply_default_content_type
1539: write_header sock, ver, path
1540: sock.write body
1541: end
# File lib/net/http.rb, line 1543
1543: def send_request_with_body_stream(sock, ver, path, f)
1544: unless content_length() or chunked?
1545: raise ArgumentError,
1546: "Content-Length not given and Transfer-Encoding is not `chunked'"
1547: end
1548: supply_default_content_type
1549: write_header sock, ver, path
1550: if chunked?
1551: while s = f.read(1024)
1552: sock.write(sprintf("%x\r\n", s.length) << s << "\r\n")
1553: end
1554: sock.write "0\r\n\r\n"
1555: else
1556: while s = f.read(1024)
1557: sock.write s
1558: end
1559: end
1560: end
# File lib/net/http.rb, line 1562
1562: def supply_default_content_type
1563: return if content_type()
1564: warn 'net/http: warning: Content-Type did not set; using application/x-www-form-urlencoded' if $VERBOSE
1565: set_content_type 'application/x-www-form-urlencoded'
1566: end