neulab/docprompting-conala huggingface dataset:
CookiePolicy.set_ok(cookie, request)  
Return boolean value indicating whether cookie should be accepted from server. cookie is a Cookie instance. request is an object implementing the interface defined by the documentation for CookieJar.extract_cookies().
class http.cookiejar.DefaultCookiePolicy(blocked_domains=None, allowed_domains=None, netscape=True, rfc2965=False, rfc2109_as_netscape=None, hide_cookie2=False, strict_domain=False, strict_rfc2965_unverifiable=True, strict_ns_unverifiable=False, strict_ns_domain=DefaultCookiePolicy.DomainLiberal, strict_ns_set_initial_dollar=False, strict_ns_set_path=False, secure_protocols=("https", "wss"))  
Constructor arguments should be passed as keyword arguments only. blocked_domains is a sequence of domain names that we never accept cookies from, nor return cookies to. allowed_domains if not None, this is a sequence of the only domains for which we accept and return cookies. secure_protocols is a sequence of protocols for which secure cookies can be added to. By default https and wss (secure websocket) are considered secure protocols. For all other arguments, see the documentation for CookiePolicy and DefaultCookiePolicy objects. DefaultCookiePolicy implements the standard accept / reject rules for Netscape and RFC 2965 cookies. By default, RFC 2109 cookies (ie. cookies received in a Set-Cookie header with a version cookie-attribute of 1) are treated according to the RFC 2965 rules. However, if RFC 2965 handling is turned off or rfc2109_as_netscape is True, RFC 2109 cookies are ‘downgraded’ by the CookieJar instance to Netscape cookies, by setting the version attribute of the Cookie instance to 0. DefaultCookiePolicy also provides some parameters to allow some fine-tuning of policy.
DefaultCookiePolicy.allowed_domains()  
Return None, or the sequence of allowed domains (as a tuple).
DefaultCookiePolicy.blocked_domains()  
Return the sequence of blocked domains (as a tuple).
DefaultCookiePolicy.DomainLiberal  
Equivalent to 0 (ie. all of the above Netscape domain strictness flags switched off).
DefaultCookiePolicy.DomainRFC2965Match  
When setting cookies, require a full RFC 2965 domain-match.
DefaultCookiePolicy.DomainStrict  
Equivalent to DomainStrictNoDots|DomainStrictNonDomain.
DefaultCookiePolicy.DomainStrictNoDots  
When setting cookies, the ‘host prefix’ must not contain a dot (eg. www.foo.bar.com can’t set a cookie for .bar.com, because www.foo contains a dot).
DefaultCookiePolicy.DomainStrictNonDomain  
Cookies that did not explicitly specify a domain cookie-attribute can only be returned to a domain equal to the domain that set the cookie (eg. spam.example.com won’t be returned cookies from example.com that had no domain cookie-attribute).
DefaultCookiePolicy.is_blocked(domain)  
Return whether domain is on the blacklist for setting or receiving cookies.
DefaultCookiePolicy.is_not_allowed(domain)  
Return whether domain is not on the whitelist for setting or receiving cookies.
DefaultCookiePolicy.rfc2109_as_netscape  
If true, request that the CookieJar instance downgrade RFC 2109 cookies (ie. cookies received in a Set-Cookie header with a version cookie-attribute of 1) to Netscape cookies by setting the version attribute of the Cookie instance to 0. The default value is None, in which case RFC 2109 cookies are downgraded if and only if RFC 2965 handling is turned off. Therefore, RFC 2109 cookies are downgraded by default.
DefaultCookiePolicy.set_allowed_domains(allowed_domains)  
Set the sequence of allowed domains, or None.
DefaultCookiePolicy.set_blocked_domains(blocked_domains)  
Set the sequence of blocked domains.
DefaultCookiePolicy.strict_domain  
Don’t allow sites to set two-component domains with country-code top-level domains like .co.uk, .gov.uk, .co.nz.etc. This is far from perfect and isn’t guaranteed to work!
DefaultCookiePolicy.strict_ns_domain  
Flags indicating how strict to be with domain-matching rules for Netscape cookies. See below for acceptable values.
DefaultCookiePolicy.strict_ns_set_initial_dollar  
Ignore cookies in Set-Cookie: headers that have names starting with '$'.
DefaultCookiePolicy.strict_ns_set_path  
Don’t allow setting cookies whose path doesn’t path-match request URI.
DefaultCookiePolicy.strict_ns_unverifiable  
Apply RFC 2965 rules on unverifiable transactions even to Netscape cookies.
DefaultCookiePolicy.strict_rfc2965_unverifiable  
Follow RFC 2965 rules on unverifiable transactions (usually, an unverifiable transaction is one resulting from a redirect or a request for an image hosted on another site). If this is false, cookies are never blocked on the basis of verifiability
class http.cookiejar.FileCookieJar(filename, delayload=None, policy=None)  
policy is an object implementing the CookiePolicy interface. For the other arguments, see the documentation for the corresponding attributes. A CookieJar which can load cookies from, and perhaps save cookies to, a file on disk. Cookies are NOT loaded from the named file until either the load() or revert() method is called. Subclasses of this class are documented in section FileCookieJar subclasses and co-operation with web browsers.  Changed in version 3.8: The filename parameter supports a path-like object.
FileCookieJar.delayload  
If true, load cookies lazily from disk. This attribute should not be assigned to. This is only a hint, since this only affects performance, not behaviour (unless the cookies on disk are changing). A CookieJar object may ignore it. None of the FileCookieJar classes included in the standard library lazily loads cookies.
FileCookieJar.filename  
Filename of default file in which to keep cookies. This attribute may be assigned to.
FileCookieJar.load(filename=None, ignore_discard=False, ignore_expires=False)  
Load cookies from a file. Old cookies are kept unless overwritten by newly loaded ones. Arguments are as for save(). The named file must be in the format understood by the class, or LoadError will be raised. Also, OSError may be raised, for example if the file does not exist.  Changed in version 3.3: IOError used to be raised, it is now an alias of OSError.
FileCookieJar.revert(filename=None, ignore_discard=False, ignore_expires=False)  
Clear all cookies and reload cookies from a saved file. revert() can raise the same exceptions as load(). If there is a failure, the object’s state will not be altered.
FileCookieJar.save(filename=None, ignore_discard=False, ignore_expires=False)  
Save cookies to a file. This base class raises NotImplementedError. Subclasses may leave this method unimplemented. filename is the name of file in which to save cookies. If filename is not specified, self.filename is used (whose default is the value passed to the constructor, if any); if self.filename is None, ValueError is raised. ignore_discard: save even cookies set to be discarded. ignore_expires: save even cookies that have expired The file is overwritten if it already exists, thus wiping all the cookies it contains. Saved cookies can be restored later using the load() or revert() methods.
exception http.cookiejar.LoadError  
Instances of FileCookieJar raise this exception on failure to load cookies from a file. LoadError is a subclass of OSError.  Changed in version 3.3: LoadError was made a subclass of OSError instead of IOError.
class http.cookiejar.LWPCookieJar(filename, delayload=None, policy=None)  
A FileCookieJar that can load from and save cookies to disk in format compatible with the libwww-perl library’s Set-Cookie3 file format. This is convenient if you want to store cookies in a human-readable file.  Changed in version 3.8: The filename parameter supports a path-like object.
class http.cookiejar.MozillaCookieJar(filename, delayload=None, policy=None)  
A FileCookieJar that can load from and save cookies to disk in the Mozilla cookies.txt file format (which is also used by the Lynx and Netscape browsers).  Note This loses information about RFC 2965 cookies, and also about newer or non-standard cookie-attributes such as port.   Warning Back up your cookies before saving if you have cookies whose loss / corruption would be inconvenient (there are some subtleties which may lead to slight changes in the file over a load / save round-trip).  Also note that cookies saved while Mozilla is running will get clobbered by Mozilla.
class http.cookies.BaseCookie([input])  
This class is a dictionary-like object whose keys are strings and whose values are Morsel instances. Note that upon setting a key to a value, the value is first converted to a Morsel containing the key and the value. If input is given, it is passed to the load() method.
BaseCookie.js_output(attrs=None)  
Return an embeddable JavaScript snippet, which, if run on a browser which supports JavaScript, will act the same as if the HTTP headers was sent. The meaning for attrs is the same as in output().
BaseCookie.load(rawdata)  
If rawdata is a string, parse it as an HTTP_COOKIE and add the values found there as Morsels. If it is a dictionary, it is equivalent to: for k, v in rawdata.items():
    cookie[k] = v
BaseCookie.output(attrs=None, header='Set-Cookie:', sep='\r\n')  
Return a string representation suitable to be sent as HTTP headers. attrs and header are sent to each Morsel’s output() method. sep is used to join the headers together, and is by default the combination '\r\n' (CRLF).
BaseCookie.value_decode(val)  
Return a tuple (real_value, coded_value) from a string representation. real_value can be any type. This method does no decoding in BaseCookie — it exists so it can be overridden.
BaseCookie.value_encode(val)  
Return a tuple (real_value, coded_value). val can be any type, but coded_value will always be converted to a string. This method does no encoding in BaseCookie — it exists so it can be overridden. In general, it should be the case that value_encode() and value_decode() are inverses on the range of value_decode.
exception http.cookies.CookieError  
Exception failing because of RFC 2109 invalidity: incorrect attributes, incorrect Set-Cookie header, etc.
class http.cookies.Morsel  
Abstract a key/value pair, which has some RFC 2109 attributes. Morsels are dictionary-like objects, whose set of keys is constant — the valid RFC 2109 attributes, which are  expires path comment domain max-age secure version httponly samesite  The attribute httponly specifies that the cookie is only transferred in HTTP requests, and is not accessible through JavaScript. This is intended to mitigate some forms of cross-site scripting. The attribute samesite specifies that the browser is not allowed to send the cookie along with cross-site requests. This helps to mitigate CSRF attacks. Valid values for this attribute are “Strict” and “Lax”. The keys are case-insensitive and their default value is ''.  Changed in version 3.5: __eq__() now takes key and value into account.   Changed in version 3.7: Attributes key, value and coded_value are read-only. Use set() for setting them.   Changed in version 3.8: Added support for the samesite attribute.
Morsel.coded_value  
The encoded value of the cookie — this is what should be sent.
Morsel.copy(value)  
Return a shallow copy of the Morsel object.  Changed in version 3.5: return a Morsel object instead of a dict.
Morsel.isReservedKey(K)  
Whether K is a member of the set of keys of a Morsel.
Morsel.js_output(attrs=None)  
Return an embeddable JavaScript snippet, which, if run on a browser which supports JavaScript, will act the same as if the HTTP header was sent. The meaning for attrs is the same as in output().
Morsel.output(attrs=None, header='Set-Cookie:')  
Return a string representation of the Morsel, suitable to be sent as an HTTP header. By default, all the attributes are included, unless attrs is given, in which case it should be a list of attributes to use. header is by default "Set-Cookie:".
Morsel.OutputString(attrs=None)  
Return a string representing the Morsel, without any surrounding HTTP or JavaScript. The meaning for attrs is the same as in output().
Morsel.set(key, value, coded_value)  
Set the key, value and coded_value attributes.
Morsel.setdefault(key, value=None)  
Raise an error if key is not a valid RFC 2109 attribute, otherwise behave the same as dict.setdefault().
Morsel.update(values)  
Update the values in the Morsel dictionary with the values in the dictionary values. Raise an error if any of the keys in the values dict is not a valid RFC 2109 attribute.  Changed in version 3.5: an error is raised for invalid keys.
class http.cookies.SimpleCookie([input])  
This class derives from BaseCookie and overrides value_decode() and value_encode(). SimpleCookie supports strings as cookie values. When setting the value, SimpleCookie calls the builtin str() to convert the value to a string. Values received from HTTP are kept as strings.
class http.HTTPStatus  
 New in version 3.5.  A subclass of enum.IntEnum that defines a set of HTTP status codes, reason phrases and long descriptions written in English. Usage: >>> from http import HTTPStatus
>>> HTTPStatus.OK
<HTTPStatus.OK: 200>
>>> HTTPStatus.OK == 200
True
>>> HTTPStatus.OK.value
200
>>> HTTPStatus.OK.phrase
'OK'
>>> HTTPStatus.OK.description
'Request fulfilled, document follows'
>>> list(HTTPStatus)
[<HTTPStatus.CONTINUE: 100>, <HTTPStatus.SWITCHING_PROTOCOLS: 101>, ...]
address_string()  
Returns the client address.  Changed in version 3.3: Previously, a name lookup was performed. To avoid name resolution delays, it now always returns the IP address.
client_address  
Contains a tuple of the form (host, port) referring to the client’s address.
close_connection  
Boolean that should be set before handle_one_request() returns, indicating if another request may be expected, or if the connection should be shut down.
date_time_string(timestamp=None)  
Returns the date and time given by timestamp (which must be None or in the format returned by time.time()), formatted for a message header. If timestamp is omitted, it uses the current date and time. The result looks like 'Sun, 06 Nov 1994 08:49:37 GMT'.
end_headers()  
Adds a blank line (indicating the end of the HTTP headers in the response) to the headers buffer and calls flush_headers().  Changed in version 3.2: The buffered headers are written to the output stream.
error_content_type  
Specifies the Content-Type HTTP header of error responses sent to the client. The default value is 'text/html'.
error_message_format  
Specifies a format string that should be used by send_error() method for building an error response to the client. The string is filled by default with variables from responses based on the status code that passed to send_error().
flush_headers()  
Finally send the headers to the output stream and flush the internal headers buffer.  New in version 3.3.
handle()  
Calls handle_one_request() once (or, if persistent connections are enabled, multiple times) to handle incoming HTTP requests. You should never need to override it; instead, implement appropriate do_*() methods.
handle_expect_100()  
When a HTTP/1.1 compliant server receives an Expect: 100-continue request header it responds back with a 100 Continue followed by 200
OK headers. This method can be overridden to raise an error if the server does not want the client to continue. For e.g. server can chose to send 417
Expectation Failed as a response header and return False.  New in version 3.2.
handle_one_request()  
This method will parse and dispatch the request to the appropriate do_*() method. You should never need to override it.
headers  
Holds an instance of the class specified by the MessageClass class variable. This instance parses and manages the headers in the HTTP request. The parse_headers() function from http.client is used to parse the headers and it requires that the HTTP request provide a valid RFC 2822 style header.
log_date_time_string()  
Returns the current date and time, formatted for logging.
log_error(...)  
Logs an error when a request cannot be fulfilled. By default, it passes the message to log_message(), so it takes the same arguments (format and additional values).
log_message(format, ...)  
Logs an arbitrary message to sys.stderr. This is typically overridden to create custom error logging mechanisms. The format argument is a standard printf-style format string, where the additional arguments to log_message() are applied as inputs to the formatting. The client ip address and current date and time are prefixed to every message logged.
log_request(code='-', size='-')  
Logs an accepted (successful) request. code should specify the numeric HTTP code associated with the response. If a size of the response is available, then it should be passed as the size parameter.
MessageClass  
Specifies an email.message.Message-like class to parse HTTP headers. Typically, this is not overridden, and it defaults to http.client.HTTPMessage.
path  
Contains the request path. If query component of the URL is present, then path includes the query. Using the terminology of RFC 3986, path here includes hier-part and the query.
protocol_version  
This specifies the HTTP protocol version used in responses. If set to 'HTTP/1.1', the server will permit HTTP persistent connections; however, your server must then include an accurate Content-Length header (using send_header()) in all of its responses to clients. For backwards compatibility, the setting defaults to 'HTTP/1.0'.
requestline  
Contains the string representation of the HTTP request line. The terminating CRLF is stripped. This attribute should be set by handle_one_request(). If no valid request line was processed, it should be set to the empty string.
request_version  
Contains the version string from the request. For example, 'HTTP/1.0'.
responses  
This attribute contains a mapping of error code integers to two-element tuples containing a short and long message. For example, {code: (shortmessage,
longmessage)}. The shortmessage is usually used as the message key in an error response, and longmessage as the explain key. It is used by send_response_only() and send_error() methods.
rfile  
An io.BufferedIOBase input stream, ready to read from the start of the optional input data.
send_error(code, message=None, explain=None)  
Sends and logs a complete error reply to the client. The numeric code specifies the HTTP error code, with message as an optional, short, human readable description of the error. The explain argument can be used to provide more detailed information about the error; it will be formatted using the error_message_format attribute and emitted, after a complete set of headers, as the response body. The responses attribute holds the default values for message and explain that will be used if no value is provided; for unknown codes the default value for both is the string ???. The body will be empty if the method is HEAD or the response code is one of the following: 1xx, 204 No Content, 205 Reset Content, 304 Not Modified.  Changed in version 3.4: The error response includes a Content-Length header. Added the explain argument.
send_header(keyword, value)  
Adds the HTTP header to an internal buffer which will be written to the output stream when either end_headers() or flush_headers() is invoked. keyword should specify the header keyword, with value specifying its value. Note that, after the send_header calls are done, end_headers() MUST BE called in order to complete the operation.  Changed in version 3.2: Headers are stored in an internal buffer.
send_response(code, message=None)  
Adds a response header to the headers buffer and logs the accepted request. The HTTP response line is written to the internal buffer, followed by Server and Date headers. The values for these two headers are picked up from the version_string() and date_time_string() methods, respectively. If the server does not intend to send any other headers using the send_header() method, then send_response() should be followed by an end_headers() call.  Changed in version 3.3: Headers are stored to an internal buffer and end_headers() needs to be called explicitly.
send_response_only(code, message=None)  
Sends the response header only, used for the purposes when 100
Continue response is sent by the server to the client. The headers not buffered and sent directly the output stream.If the message is not specified, the HTTP message corresponding the response code is sent.  New in version 3.2.
server_version  
Specifies the server software version. You may want to override this. The format is multiple whitespace-separated strings, where each string is of the form name[/version]. For example, 'BaseHTTP/0.2'.
sys_version  
Contains the Python system version, in a form usable by the version_string method and the server_version class variable. For example, 'Python/1.4'.
version_string()  
Returns the server software’s version string. This is a combination of the server_version and sys_version attributes.
wfile  
Contains the output stream for writing a response back to the client. Proper adherence to the HTTP protocol must be used when writing to this stream in order to achieve successful interoperation with HTTP clients.  Changed in version 3.6: This is an io.BufferedIOBase stream.
class http.server.CGIHTTPRequestHandler(request, client_address, server)  
This class is used to serve either files or output of CGI scripts from the current directory and below. Note that mapping HTTP hierarchic structure to local directory structure is exactly as in SimpleHTTPRequestHandler.  Note CGI scripts run by the CGIHTTPRequestHandler class cannot execute redirects (HTTP code 302), because code 200 (script output follows) is sent prior to execution of the CGI script. This pre-empts the status code.  The class will however, run the CGI script, instead of serving it as a file, if it guesses it to be a CGI script. Only directory-based CGI are used — the other common server configuration is to treat special extensions as denoting CGI scripts. The do_GET() and do_HEAD() functions are modified to run CGI scripts and serve the output, instead of serving files, if the request leads to somewhere below the cgi_directories path. The CGIHTTPRequestHandler defines the following data member:  
cgi_directories  
This defaults to ['/cgi-bin', '/htbin'] and describes directories to treat as containing CGI scripts. 
 The CGIHTTPRequestHandler defines the following method:  
do_POST()  
This method serves the 'POST' request type, only allowed for CGI scripts. Error 501, “Can only POST to CGI scripts”, is output when trying to POST to a non-CGI url. 
 Note that CGI scripts will be run with UID of user nobody, for security reasons. Problems with the CGI script will be translated to error 403.
cgi_directories  
This defaults to ['/cgi-bin', '/htbin'] and describes directories to treat as containing CGI scripts.
do_POST()  
This method serves the 'POST' request type, only allowed for CGI scripts. Error 501, “Can only POST to CGI scripts”, is output when trying to POST to a non-CGI url.
class http.server.HTTPServer(server_address, RequestHandlerClass)  
This class builds on the TCPServer class by storing the server address as instance variables named server_name and server_port. The server is accessible by the handler, typically through the handler’s server instance variable.