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 1470 1470: def initialize(m, reqbody, resbody, path, initheader = nil) 1471: @method = m 1472: @request_has_body = reqbody 1473: @response_has_body = resbody 1474: raise ArgumentError, "HTTP request path is empty" if path.empty? 1475: @path = path 1476: initialize_http_header initheader 1477: self['Accept'] ||= '*/*' 1478: @body = nil 1479: @body_stream = nil 1480: end
# File lib/net/http.rb, line 1504 1504: def body=(str) 1505: @body = str 1506: @body_stream = nil 1507: str 1508: end
# File lib/net/http.rb, line 1497 1497: def body_exist? 1498: warn "Net::HTTPRequest#body_exist? is obsolete; use response_body_permitted?" if $VERBOSE 1499: response_body_permitted? 1500: end
# File lib/net/http.rb, line 1512 1512: def body_stream=(input) 1513: @body = nil 1514: @body_stream = input 1515: input 1516: end
# File lib/net/http.rb, line 1489 1489: def request_body_permitted? 1490: @request_has_body 1491: end
# File lib/net/http.rb, line 1493 1493: def response_body_permitted? 1494: @response_has_body 1495: end
# File lib/net/http.rb, line 1539 1539: def send_request_with_body(sock, ver, path, body) 1540: self.content_length = body.length 1541: delete 'Transfer-Encoding' 1542: supply_default_content_type 1543: write_header sock, ver, path 1544: sock.write body 1545: end
# File lib/net/http.rb, line 1547 1547: def send_request_with_body_stream(sock, ver, path, f) 1548: unless content_length() or chunked? 1549: raise ArgumentError, 1550: "Content-Length not given and Transfer-Encoding is not `chunked'" 1551: end 1552: supply_default_content_type 1553: write_header sock, ver, path 1554: if chunked? 1555: while s = f.read(1024) 1556: sock.write(sprintf("%x\r\n", s.length) << s << "\r\n") 1557: end 1558: sock.write "0\r\n\r\n" 1559: else 1560: while s = f.read(1024) 1561: sock.write s 1562: end 1563: end 1564: end
# File lib/net/http.rb, line 1566 1566: def supply_default_content_type 1567: return if content_type() 1568: warn 'net/http: warning: Content-Type did not set; using application/x-www-form-urlencoded' if $VERBOSE 1569: set_content_type 'application/x-www-form-urlencoded' 1570: end