| 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 1475
1475: def initialize(m, reqbody, resbody, path, initheader = nil)
1476: @method = m
1477: @request_has_body = reqbody
1478: @response_has_body = resbody
1479: raise ArgumentError, "HTTP request path is empty" if path.empty?
1480: @path = path
1481: initialize_http_header initheader
1482: self['Accept'] ||= '*/*'
1483: @body = nil
1484: @body_stream = nil
1485: end
# File lib/net/http.rb, line 1509
1509: def body=(str)
1510: @body = str
1511: @body_stream = nil
1512: str
1513: end
# File lib/net/http.rb, line 1502
1502: def body_exist?
1503: warn "Net::HTTPRequest#body_exist? is obsolete; use response_body_permitted?" if $VERBOSE
1504: response_body_permitted?
1505: end
# File lib/net/http.rb, line 1517
1517: def body_stream=(input)
1518: @body = nil
1519: @body_stream = input
1520: input
1521: end
# File lib/net/http.rb, line 1494
1494: def request_body_permitted?
1495: @request_has_body
1496: end
# File lib/net/http.rb, line 1498
1498: def response_body_permitted?
1499: @response_has_body
1500: end
# File lib/net/http.rb, line 1544
1544: def send_request_with_body(sock, ver, path, body)
1545: self.content_length = body.length
1546: delete 'Transfer-Encoding'
1547: supply_default_content_type
1548: write_header sock, ver, path
1549: sock.write body
1550: end
# File lib/net/http.rb, line 1552
1552: def send_request_with_body_stream(sock, ver, path, f)
1553: unless content_length() or chunked?
1554: raise ArgumentError,
1555: "Content-Length not given and Transfer-Encoding is not `chunked'"
1556: end
1557: supply_default_content_type
1558: write_header sock, ver, path
1559: if chunked?
1560: while s = f.read(1024)
1561: sock.write(sprintf("%x\r\n", s.length) << s << "\r\n")
1562: end
1563: sock.write "0\r\n\r\n"
1564: else
1565: while s = f.read(1024)
1566: sock.write s
1567: end
1568: end
1569: end
# File lib/net/http.rb, line 1571
1571: def supply_default_content_type
1572: return if content_type()
1573: warn 'net/http: warning: Content-Type did not set; using application/x-www-form-urlencoded' if $VERBOSE
1574: set_content_type 'application/x-www-form-urlencoded'
1575: end