⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.133
Server IP:
185.119.109.197
Server:
Linux managedhosting.chostar.me 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.1.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
ri
/
3.0.0
/
system
/
Net
/
HTTP
/
View File Name :
cdesc-HTTP.ri
U:RDoc::NormalClass[iI" HTTP:ETI"Net::HTTP;TI" Protocol;To:RDoc::Markup::Document:@parts[o;;[{S:RDoc::Markup::Heading: leveli: textI"!An HTTP client API for Ruby.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Paragraph;[I"GNet::HTTP provides a rich library which can be used to build HTTP ;TI"3user-agents. For more details about HTTP see ;TI"4[RFC2616](http://www.ietf.org/rfc/rfc2616.txt).;T@o; ;[I"FNet::HTTP is designed to work closely with URI. URI::HTTP#host, ;TI"HURI::HTTP#port and URI::HTTP#request_uri are designed to work with ;TI"Net::HTTP.;T@o; ;[I"JIf you are only performing a few GET requests you should try OpenURI.;T@S; ; i;I"Simple Examples;T@o; ;[I"8All examples assume you have loaded Net::HTTP with:;T@o:RDoc::Markup::Verbatim;[I"require 'net/http' ;T:@format0o; ;[I"MThis will also require 'uri' so you don't need to require it separately.;T@o; ;[I"CThe Net::HTTP methods in the following section do not persist ;TI"Lconnections. They are not recommended if you are performing many HTTP ;TI"requests.;T@S; ; i;I"GET;T@o;;[I"=Net::HTTP.get('example.com', '/index.html') # => String ;T;0S; ; i;I"GET by URI;T@o;;[I"9uri = URI('http://example.com/index.html?count=10') ;TI"$Net::HTTP.get(uri) # => String ;T;0S; ; i;I" GET with Dynamic Parameters;T@o;;[I"0uri = URI('http://example.com/index.html') ;TI"+params = { :limit => 10, :page => 3 } ;TI"-uri.query = URI.encode_www_form(params) ;TI" ;TI"'res = Net::HTTP.get_response(uri) ;TI"2puts res.body if res.is_a?(Net::HTTPSuccess) ;T;0S; ; i;I" POST;T@o;;[I"4uri = URI('http://www.example.com/search.cgi') ;TI"Bres = Net::HTTP.post_form(uri, 'q' => 'ruby', 'max' => '50') ;TI"puts res.body ;T;0S; ; i;I"POST with Multiple Values;T@o;;[I"4uri = URI('http://www.example.com/search.cgi') ;TI"Lres = Net::HTTP.post_form(uri, 'q' => ['ruby', 'perl'], 'max' => '50') ;TI"puts res.body ;T;0S; ; i;I"How to use Net::HTTP;T@o; ;[I"OThe following example code can be used as the basis of an HTTP user-agent ;TI"Cwhich can perform a variety of request types using persistent ;TI"connections.;T@o;;[I"
String ;TI"-res.get_fields('set-cookie') # => Array ;TI"-res.to_hash['set-cookie'] # => Array ;TI",puts "Headers: #{res.to_hash.inspect}" ;TI" ;TI"# Status ;TI"$puts res.code # => '200' ;TI"#puts res.message # => 'OK' ;TI"'puts res.class.name # => 'HTTPOK' ;TI" ;TI"# Body ;TI"3puts res.body if res.response_body_permitted? ;T;0S; ; i;I"Following Redirection;T@o; ;[I"LEach Net::HTTPResponse object belongs to a class for its response code.;T@o; ;[ I"HFor example, all 2XX responses are instances of a Net::HTTPSuccess ;TI"Gsubclass, a 3XX response is an instance of a Net::HTTPRedirection ;TI"Osubclass and a 200 response is an instance of the Net::HTTPOK class. For ;TI"Jdetails of response classes, see the section "HTTP Response Classes" ;TI"below.;T@o; ;[I"OUsing a case statement you can handle various types of responses properly:;T@o;;[I"$def fetch(uri_str, limit = 10) ;TI"/ # You should choose a better exception. ;TI"D raise ArgumentError, 'too many HTTP redirects' if limit == 0 ;TI" ;TI"7 response = Net::HTTP.get_response(URI(uri_str)) ;TI" ;TI" case response ;TI"" when Net::HTTPSuccess then ;TI" response ;TI"& when Net::HTTPRedirection then ;TI") location = response['location'] ;TI"* warn "redirected to #{location}" ;TI"$ fetch(location, limit - 1) ;TI" else ;TI" response.value ;TI" end ;TI" end ;TI" ;TI"-print fetch('http://www.ruby-lang.org') ;T;0S; ; i;I" POST;T@o; ;[I"OA POST can be made using the Net::HTTP::Post request class. This example ;TI"%creates a URL encoded POST body:;T@o;;[I"2uri = URI('http://www.example.com/todo.cgi') ;TI"$req = Net::HTTP::Post.new(uri) ;TI"Ereq.set_form_data('from' => '2005-01-01', 'to' => '2005-03-31') ;TI" ;TI"=res = Net::HTTP.start(uri.hostname, uri.port) do |http| ;TI" http.request(req) ;TI" end ;TI" ;TI"case res ;TI"1when Net::HTTPSuccess, Net::HTTPRedirection ;TI" # OK ;TI" else ;TI" res.value ;TI" end ;T;0o; ;[I">To send multipart/form-data use Net::HTTPHeader#set_form:;T@o;;[I"$req = Net::HTTP::Post.new(uri) ;TI"Mreq.set_form([['upload', File.open('foo.bar')]], 'multipart/form-data') ;T;0o; ;[I"NOther requests that can contain a body such as PUT can be created in the ;TI"Esame way using the corresponding request class (Net::HTTP::Put).;T@S; ; i;I"Setting Headers;T@o; ;[ I"@The following example performs a conditional GET using the ;TI"MIf-Modified-Since header. If the files has not been modified since the ;TI"Ptime in the header a Not Modified response will be returned. See RFC 2616 ;TI"%section 9.3 for further details.;T@o;;[I"5uri = URI('http://example.com/cached_response') ;TI"(file = File.stat 'cached_response' ;TI" ;TI"#req = Net::HTTP::Get.new(uri) ;TI"3req['If-Modified-Since'] = file.mtime.rfc2822 ;TI" ;TI";res = Net::HTTP.start(uri.hostname, uri.port) {|http| ;TI" http.request(req) ;TI"} ;TI" ;TI")open 'cached_response', 'w' do |io| ;TI" io.write res.body ;TI"(end if res.is_a?(Net::HTTPSuccess) ;T;0S; ; i;I"Basic Authentication;T@o; ;[I"4Basic authentication is performed according to ;TI"4[RFC2617](http://www.ietf.org/rfc/rfc2617.txt).;T@o;;[I":uri = URI('http://example.com/index.html?key=value') ;TI" ;TI"#req = Net::HTTP::Get.new(uri) ;TI"#req.basic_auth 'user', 'pass' ;TI" ;TI";res = Net::HTTP.start(uri.hostname, uri.port) {|http| ;TI" http.request(req) ;TI"} ;TI"puts res.body ;T;0S; ; i;I"Streaming Response Bodies;T@o; ;[I"LBy default Net::HTTP reads an entire response into memory. If you are ;TI"Nhandling large files or wish to implement a progress bar you can instead ;TI"'stream the body directly to an IO.;T@o;;[I"0uri = URI('http://example.com/large_file') ;TI" ;TI"3Net::HTTP.start(uri.host, uri.port) do |http| ;TI"( request = Net::HTTP::Get.new uri ;TI" ;TI"* http.request request do |response| ;TI"( open 'large_file', 'w' do |io| ;TI") response.read_body do |chunk| ;TI" io.write chunk ;TI" end ;TI" end ;TI" end ;TI" end ;T;0S; ; i;I" HTTPS;T@o; ;[I"CHTTPS is enabled for an HTTP connection by Net::HTTP#use_ssl=.;T@o;;[I"Duri = URI('https://secure.example.com/some_path?query=string') ;TI" ;TI"ENet::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| ;TI"( request = Net::HTTP::Get.new uri ;TI"B response = http.request request # Net::HTTPResponse object ;TI" end ;T;0o; ;[I"IOr if you simply want to make a GET request, you may pass in an URI ;TI"Hobject that has an HTTPS URL. Net::HTTP automatically turns on TLS ;TI"=verification if the URI object has a 'https' URI scheme.;T@o;;[I"'uri = URI('https://example.com/') ;TI"$Net::HTTP.get(uri) # => String ;T;0o; ;[I"OIn previous versions of Ruby you would need to require 'net/https' to use ;TI"#HTTPS. This is no longer true.;T@S; ; i;I"Proxies;T@o; ;[I"GNet::HTTP will automatically create a proxy from the +http_proxy+ ;TI"Menvironment variable if it is present. To disable use of +http_proxy+, ;TI"&pass +nil+ for the proxy address.;T@o; ;[I"(You may also create a custom proxy:;T@o;;[I"$proxy_addr = 'your.proxy.host' ;TI"proxy_port = 8080 ;TI" ;TI"NNet::HTTP.new('example.com', nil, proxy_addr, proxy_port).start { |http| ;TI"/ # always proxy via your.proxy.addr:8080 ;TI"} ;T;0o; ;[I"MSee Net::HTTP.new for further details and examples such as proxies that ;TI"%require a username and password.;T@S; ; i;I"Compression;T@o; ;[I"NNet::HTTP automatically adds Accept-Encoding for compression of response ;TI"Obodies and automatically decompresses gzip and deflate responses unless a ;TI"Range header was sent.;T@o; ;[I"NCompression can be disabled through the Accept-Encoding: identity header.;T@S; ; i;I"HTTP Request Classes;T@o; ;[I".Here is the HTTP request class hierarchy.;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"Net::HTTPRequest;To;;;;[o;;0;[o; ;[I"Net::HTTP::Get;To;;0;[o; ;[I"Net::HTTP::Head;To;;0;[o; ;[I"Net::HTTP::Post;To;;0;[o; ;[I"Net::HTTP::Patch;To;;0;[o; ;[I"Net::HTTP::Put;To;;0;[o; ;[I"Net::HTTP::Proppatch;To;;0;[o; ;[I"Net::HTTP::Lock;To;;0;[o; ;[I"Net::HTTP::Unlock;To;;0;[o; ;[I"Net::HTTP::Options;To;;0;[o; ;[I"Net::HTTP::Propfind;To;;0;[o; ;[I"Net::HTTP::Delete;To;;0;[o; ;[I"Net::HTTP::Move;To;;0;[o; ;[I"Net::HTTP::Copy;To;;0;[o; ;[I"Net::HTTP::Mkcol;To;;0;[o; ;[I"Net::HTTP::Trace;T@S; ; i;I"HTTP Response Classes;T@o; ;[I"LHere is HTTP response class hierarchy. All classes are defined in Net ;TI"4module and are subclasses of Net::HTTPResponse.;T@o;;: NOTE;[?o;;[I"HTTPUnknownResponse;T;[o; ;[I""For unhandled HTTP extensions;To;;[I"HTTPInformation;T;[o; ;[I"1xx;To;;[I"HTTPContinue;T;[o; ;[I"100;To;;[I"HTTPSwitchProtocol;T;[o; ;[I"101;To;;[I"HTTPSuccess;T;[o; ;[I"2xx;To;;[I"HTTPOK;T;[o; ;[I"200;To;;[I"HTTPCreated;T;[o; ;[I"201;To;;[I"HTTPAccepted;T;[o; ;[I"202;To;;[I"$HTTPNonAuthoritativeInformation;T;[o; ;[I"203;To;;[I"HTTPNoContent;T;[o; ;[I"204;To;;[I"HTTPResetContent;T;[o; ;[I"205;To;;[I"HTTPPartialContent;T;[o; ;[I"206;To;;[I"HTTPMultiStatus;T;[o; ;[I"207;To;;[I"HTTPIMUsed;T;[o; ;[I"226;To;;[I"HTTPRedirection;T;[o; ;[I"3xx;To;;[I"HTTPMultipleChoices;T;[o; ;[I"300;To;;[I"HTTPMovedPermanently;T;[o; ;[I"301;To;;[I"HTTPFound;T;[o; ;[I"302;To;;[I"HTTPSeeOther;T;[o; ;[I"303;To;;[I"HTTPNotModified;T;[o; ;[I"304;To;;[I"HTTPUseProxy;T;[o; ;[I"305;To;;[I"HTTPTemporaryRedirect;T;[o; ;[I"307;To;;[I"HTTPClientError;T;[o; ;[I"4xx;To;;[I"HTTPBadRequest;T;[o; ;[I"400;To;;[I"HTTPUnauthorized;T;[o; ;[I"401;To;;[I"HTTPPaymentRequired;T;[o; ;[I"402;To;;[I"HTTPForbidden;T;[o; ;[I"403;To;;[I"HTTPNotFound;T;[o; ;[I"404;To;;[I"HTTPMethodNotAllowed;T;[o; ;[I"405;To;;[I"HTTPNotAcceptable;T;[o; ;[I"406;To;;[I"$HTTPProxyAuthenticationRequired;T;[o; ;[I"407;To;;[I"HTTPRequestTimeOut;T;[o; ;[I"408;To;;[I"HTTPConflict;T;[o; ;[I"409;To;;[I" HTTPGone;T;[o; ;[I"410;To;;[I"HTTPLengthRequired;T;[o; ;[I"411;To;;[I"HTTPPreconditionFailed;T;[o; ;[I"412;To;;[I"HTTPRequestEntityTooLarge;T;[o; ;[I"413;To;;[I"HTTPRequestURITooLong;T;[o; ;[I"414;To;;[I"HTTPUnsupportedMediaType;T;[o; ;[I"415;To;;[I"%HTTPRequestedRangeNotSatisfiable;T;[o; ;[I"416;To;;[I"HTTPExpectationFailed;T;[o; ;[I"417;To;;[I"HTTPUnprocessableEntity;T;[o; ;[I"422;To;;[I"HTTPLocked;T;[o; ;[I"423;To;;[I"HTTPFailedDependency;T;[o; ;[I"424;To;;[I"HTTPUpgradeRequired;T;[o; ;[I"426;To;;[I"HTTPPreconditionRequired;T;[o; ;[I"428;To;;[I"HTTPTooManyRequests;T;[o; ;[I"429;To;;[I"$HTTPRequestHeaderFieldsTooLarge;T;[o; ;[I"431;To;;[I"#HTTPUnavailableForLegalReasons;T;[o; ;[I"451;To;;[I"HTTPServerError;T;[o; ;[I"5xx;To;;[I"HTTPInternalServerError;T;[o; ;[I"500;To;;[I"HTTPNotImplemented;T;[o; ;[I"501;To;;[I"HTTPBadGateway;T;[o; ;[I"502;To;;[I"HTTPServiceUnavailable;T;[o; ;[I"503;To;;[I"HTTPGatewayTimeOut;T;[o; ;[I"504;To;;[I"HTTPVersionNotSupported;T;[o; ;[I"505;To;;[I"HTTPInsufficientStorage;T;[o; ;[I"507;To;;[I"&HTTPNetworkAuthenticationRequired;T;[o; ;[I"511;T@o; ;[I"KThere is also the Net::HTTPBadResponse exception which is raised when ;TI"there is a protocol error.;T: @fileI"lib/net/http.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[([ I"proxy_address;TI"R;T:publicTI"lib/net/http.rb;T[ I"proxy_pass;T@@;T@A[ I"proxy_port;T@@;T@A[ I"proxy_user;T@@;T@A[ I"address;T@@;F@A[ I"ca_file;TI"RW;T;F@A[ I"ca_path;T@L;F@A[ I" cert;T@L;F@A[ I"cert_store;T@L;F@A[ I"ciphers;T@L;F@A[ I"close_on_empty_response;T@L;F@A[ I"continue_timeout;T@@;F@A[ I"extra_chain_cert;T@L;F@A[ I"keep_alive_timeout;T@L;F@A[ I"key;T@L;F@A[ I"local_host;T@L;F@A[ I"local_port;T@L;F@A[ I"max_retries;T@@;F@A[ I"max_version;T@L;F@A[ I"min_version;T@L;F@A[ I"open_timeout;T@L;F@A[ I" port;T@@;F@A[ I"proxy_address;TI"W;T;F@A[ I"proxy_from_env;T@o;F@A[ I"proxy_pass;T@o;F@A[ I"proxy_port;T@o;F@A[ I"proxy_user;T@o;F@A[ I"read_timeout;T@@;F@A[ I"ssl_timeout;T@L;F@A[ I"ssl_version;T@L;F@A[ I"verify_callback;T@L;F@A[ I"verify_depth;T@L;F@A[ I"verify_hostname;T@L;F@A[ I"verify_mode;T@L;F@A[ I"write_timeout;T@@;F@A[ U:RDoc::Constant[i I"SSL_IVNAMES;TI"Net::HTTP::SSL_IVNAMES;T;0o;;[ ;@<;0@<@cRDoc::NormalClass0U;[i I"SSL_ATTRIBUTES;TI"Net::HTTP::SSL_ATTRIBUTES;T;0o;;[ ;@<;0@<@@0U;[i I"+ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE;TI"6Net::HTTP::ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE;T;0o;;[ ;@<;0@<@@0U;[i I"STATUS_CODES;TI"Net::HTTP::STATUS_CODES;T;0o;;[ ;I"lib/net/http/status.rb;T;0@¢@@0[ [[I" class;T[[;[[I" Proxy;T@A[I"default_port;T@A[I"get;T@A[I"get_print;T@A[I"get_response;T@A[I"http_default_port;T@A[I"https_default_port;T@A[I"is_version_1_2?;T@A[I"new;T@A[I"newobj;T@A[I" post;T@A[I"post_form;T@A[I"proxy_class?;T@A[I" start;T@A[I"version_1_2;T@A[I"version_1_2?;T@A[:protected[ [:private[ [I" instance;T[[;[2[I"active?;T@A[I"continue_timeout=;T@A[I" copy;T@A[I"delete;T@A[I"finish;T@A[I"get;T@A[I" get2;T@A[I" head;T@A[I" head2;T@A[I"inspect;T@A[I"ipaddr;T@A[I"ipaddr=;T@A[I" lock;T@A[I"max_retries=;T@A[I" mkcol;T@A[I" move;T@A[I"options;T@A[I" patch;T@A[I"peer_cert;T@A[I" post;T@A[I" post2;T@A[I" propfind;T@A[I"proppatch;T@A[I"proxy?;T@A[I"proxy_address;T@A[I"proxy_from_env?;T@A[I"proxy_pass;T@A[I"proxy_port;T@A[I"proxy_user;T@A[I"proxyaddr;T@A[I"proxyport;T@A[I"read_timeout=;T@A[I"request;T@A[I"request_get;T@A[I"request_head;T@A[I"request_post;T@A[I"send_request;T@A[I"set_debug_output;T@A[I" start;T@A[I" started?;T@A[I" trace;T@A[I"unlock;T@A[I" use_ssl=;T@A[I" use_ssl?;T@A[I"write_timeout=;T@A[;[ [;[[I"D;T@A[I"addr_port;T@A[I"begin_transport;T@A[I"connect;T@A[I"do_finish;T@A[I" do_start;T@A[I"edit_path;T@A[I"end_transport;T@A[I"keep_alive?;T@A[I"on_connect;T@A[I"send_entity;T@A[I"sspi_auth;T@A[I"sspi_auth?;T@A[I"transport_request;T@A[ [U:RDoc::Context::Section[i 0o;;[ ;0;0[ @<I"$lib/net/http/generic_request.rb;TI" lib/net/http/proxy_delta.rb;TI"lib/net/http/requests.rb;T@¢I"lib/open-uri.rb;TI"#lib/rubygems/remote_fetcher.rb;TI""lib/rubygems/s3_uri_signer.rb;TI"Net;TcRDoc::NormalModule