Internet Protocols and Support
******************************

The modules described in this chapter implement internet protocols and
support for related technology.  They are all implemented in Python.
Most of these modules require the presence of the system-dependent
module "socket", which is currently supported on most popular
platforms.  Here is an overview:

* "webbrowser" — Convenient web-browser controller

  * "Error"

  * "open()"

  * "open_new()"

  * "open_new_tab()"

  * "get()"

  * "register()"

  * Browser Controller Objects

    * "name"

    * "open()"

    * "open_new()"

    * "open_new_tab()"

* "wsgiref" — WSGI Utilities and Reference Implementation

  * "wsgiref.util" – WSGI environment utilities

    * "guess_scheme()"

    * "request_uri()"

    * "application_uri()"

    * "shift_path_info()"

    * "setup_testing_defaults()"

    * "is_hop_by_hop()"

    * "FileWrapper"

  * "wsgiref.headers" – WSGI response header tools

    * "Headers"

      * "get_all()"

      * "add_header()"

  * "wsgiref.simple_server" – a simple WSGI HTTP server

    * "make_server()"

    * "demo_app()"

    * "WSGIServer"

      * "set_app()"

      * "get_app()"

    * "WSGIRequestHandler"

      * "get_environ()"

      * "get_stderr()"

      * "handle()"

  * "wsgiref.validate" — WSGI conformance checker

    * "validator()"

  * "wsgiref.handlers" – server/gateway base classes

    * "CGIHandler"

    * "IISCGIHandler"

    * "BaseCGIHandler"

    * "SimpleHandler"

    * "BaseHandler"

      * "run()"

      * "_write()"

      * "_flush()"

      * "get_stdin()"

      * "get_stderr()"

      * "add_cgi_vars()"

      * "wsgi_multithread"

      * "wsgi_multiprocess"

      * "wsgi_run_once"

      * "os_environ"

      * "server_software"

      * "get_scheme()"

      * "setup_environ()"

      * "log_exception()"

      * "traceback_limit"

      * "error_output()"

      * "error_status"

      * "error_headers"

      * "error_body"

      * "wsgi_file_wrapper"

      * "sendfile()"

      * "origin_server"

      * "http_version"

    * "read_environ()"

  * "wsgiref.types" – WSGI types for static type checking

    * "StartResponse"

    * "WSGIEnvironment"

    * "WSGIApplication"

    * "InputStream"

    * "ErrorStream"

    * "FileWrapper"

  * Examples

* "urllib" — URL handling modules

* "urllib.request" — Extensible library for opening URLs

  * "urlopen()"

  * "install_opener()"

  * "build_opener()"

  * "pathname2url()"

  * "url2pathname()"

  * "getproxies()"

  * "Request"

  * "OpenerDirector"

  * "BaseHandler"

  * "HTTPDefaultErrorHandler"

  * "HTTPRedirectHandler"

  * "HTTPCookieProcessor"

  * "ProxyHandler"

  * "HTTPPasswordMgr"

  * "HTTPPasswordMgrWithDefaultRealm"

  * "HTTPPasswordMgrWithPriorAuth"

  * "AbstractBasicAuthHandler"

  * "HTTPBasicAuthHandler"

  * "ProxyBasicAuthHandler"

  * "AbstractDigestAuthHandler"

  * "HTTPDigestAuthHandler"

  * "ProxyDigestAuthHandler"

  * "HTTPHandler"

  * "HTTPSHandler"

  * "FileHandler"

  * "DataHandler"

  * "FTPHandler"

  * "CacheFTPHandler"

  * "UnknownHandler"

  * "HTTPErrorProcessor"

  * Request Objects

    * "full_url"

    * "type"

    * "host"

    * "origin_req_host"

    * "selector"

    * "data"

    * "unverifiable"

    * "method"

    * "get_method()"

    * "add_header()"

    * "add_unredirected_header()"

    * "has_header()"

    * "remove_header()"

    * "get_full_url()"

    * "set_proxy()"

    * "get_header()"

    * "header_items()"

  * OpenerDirector Objects

    * "add_handler()"

    * "open()"

    * "error()"

  * BaseHandler Objects

    * "add_parent()"

    * "close()"

    * "parent"

    * "default_open()"

    * "unknown_open()"

    * "http_error_default()"

  * HTTPRedirectHandler Objects

    * "redirect_request()"

    * "http_error_301()"

    * "http_error_302()"

    * "http_error_303()"

    * "http_error_307()"

    * "http_error_308()"

  * HTTPCookieProcessor Objects

    * "cookiejar"

  * ProxyHandler Objects

  * HTTPPasswordMgr Objects

    * "add_password()"

    * "find_user_password()"

  * HTTPPasswordMgrWithPriorAuth Objects

    * "add_password()"

    * "find_user_password()"

    * "update_authenticated()"

    * "is_authenticated()"

  * AbstractBasicAuthHandler Objects

    * "http_error_auth_reqed()"

  * HTTPBasicAuthHandler Objects

    * "http_error_401()"

  * ProxyBasicAuthHandler Objects

    * "http_error_407()"

  * AbstractDigestAuthHandler Objects

    * "http_error_auth_reqed()"

  * HTTPDigestAuthHandler Objects

    * "http_error_401()"

  * ProxyDigestAuthHandler Objects

    * "http_error_407()"

  * HTTPHandler Objects

    * "http_open()"

  * HTTPSHandler Objects

    * "https_open()"

  * FileHandler Objects

    * "file_open()"

  * DataHandler Objects

    * "data_open()"

  * FTPHandler Objects

    * "ftp_open()"

  * CacheFTPHandler Objects

    * "setTimeout()"

    * "setMaxConns()"

  * UnknownHandler Objects

    * "unknown_open()"

  * HTTPErrorProcessor Objects

    * "http_response()"

    * "https_response()"

  * Examples

  * Legacy interface

    * "urlretrieve()"

    * "urlcleanup()"

    * "URLopener"

      * "open()"

      * "open_unknown()"

      * "retrieve()"

      * "version"

    * "FancyURLopener"

      * "prompt_user_passwd()"

  * "urllib.request" Restrictions

* "urllib.response" — Response classes used by urllib

  * "addinfourl"

    * "url"

    * "headers"

    * "status"

    * "geturl()"

    * "info()"

    * "code"

    * "getcode()"

* "urllib.parse" — Parse URLs into components

  * URL Parsing

    * "urlparse()"

    * "parse_qs()"

    * "parse_qsl()"

    * "urlunparse()"

    * "urlsplit()"

    * "urlunsplit()"

    * "urljoin()"

    * "urldefrag()"

    * "unwrap()"

  * URL parsing security

  * Parsing ASCII Encoded Bytes

  * Structured Parse Results

    * "geturl()"

    * "DefragResult"

    * "ParseResult"

    * "SplitResult"

    * "DefragResultBytes"

    * "ParseResultBytes"

    * "SplitResultBytes"

  * URL Quoting

    * "quote()"

    * "quote_plus()"

    * "quote_from_bytes()"

    * "unquote()"

    * "unquote_plus()"

    * "unquote_to_bytes()"

    * "urlencode()"

* "urllib.error" — Exception classes raised by urllib.request

  * "URLError"

    * "reason"

  * "HTTPError"

    * "url"

    * "code"

    * "reason"

    * "headers"

    * "fp"

  * "ContentTooShortError"

    * "content"

* "urllib.robotparser" —  Parser for robots.txt

  * "RobotFileParser"

    * "set_url()"

    * "read()"

    * "parse()"

    * "can_fetch()"

    * "mtime()"

    * "modified()"

    * "crawl_delay()"

    * "request_rate()"

    * "site_maps()"

* "http" — HTTP modules

  * "HTTPStatus"

  * HTTP status codes

  * HTTP status category

    * "HTTPMethod"

  * HTTP methods

* "http.client" — HTTP protocol client

  * "HTTPConnection"

  * "HTTPSConnection"

  * "HTTPResponse"

  * "parse_headers()"

  * "HTTPException"

  * "NotConnected"

  * "InvalidURL"

  * "UnknownProtocol"

  * "UnknownTransferEncoding"

  * "UnimplementedFileMode"

  * "IncompleteRead"

  * "ImproperConnectionState"

  * "CannotSendRequest"

  * "CannotSendHeader"

  * "ResponseNotReady"

  * "BadStatusLine"

  * "LineTooLong"

  * "RemoteDisconnected"

  * "HTTP_PORT"

  * "HTTPS_PORT"

  * "responses"

  * HTTPConnection Objects

    * "request()"

    * "getresponse()"

    * "set_debuglevel()"

    * "set_tunnel()"

    * "get_proxy_response_headers()"

    * "connect()"

    * "close()"

    * "blocksize"

    * "putrequest()"

    * "putheader()"

    * "endheaders()"

    * "send()"

  * HTTPResponse Objects

    * "read()"

    * "readinto()"

    * "getheader()"

    * "getheaders()"

    * "fileno()"

    * "msg"

    * "version"

    * "url"

    * "headers"

    * "status"

    * "reason"

    * "debuglevel"

    * "closed"

    * "geturl()"

    * "info()"

    * "getcode()"

  * Examples

  * HTTPMessage Objects

    * "HTTPMessage"

* "ftplib" — FTP protocol client

  * Reference

    * FTP objects

      * "FTP"

        * "set_debuglevel()"

        * "connect()"

        * "getwelcome()"

        * "login()"

        * "abort()"

        * "sendcmd()"

        * "voidcmd()"

        * "retrbinary()"

        * "retrlines()"

        * "set_pasv()"

        * "storbinary()"

        * "storlines()"

        * "transfercmd()"

        * "ntransfercmd()"

        * "mlsd()"

        * "nlst()"

        * "dir()"

        * "rename()"

        * "delete()"

        * "cwd()"

        * "mkd()"

        * "pwd()"

        * "rmd()"

        * "size()"

        * "quit()"

        * "close()"

    * FTP_TLS objects

      * "FTP_TLS"

        * "ssl_version"

        * "auth()"

        * "ccc()"

        * "prot_p()"

        * "prot_c()"

    * Module variables

      * "error_reply"

      * "error_temp"

      * "error_perm"

      * "error_proto"

      * "all_errors"

* "poplib" — POP3 protocol client

  * "POP3"

  * "POP3_SSL"

  * "error_proto"

  * POP3 Objects

    * "set_debuglevel()"

    * "getwelcome()"

    * "capa()"

    * "user()"

    * "pass_()"

    * "apop()"

    * "rpop()"

    * "stat()"

    * "list()"

    * "retr()"

    * "dele()"

    * "rset()"

    * "noop()"

    * "quit()"

    * "top()"

    * "uidl()"

    * "utf8()"

    * "stls()"

  * POP3 Example

* "imaplib" — IMAP4 protocol client

  * "IMAP4"

  * "error"

  * "abort"

  * "readonly"

  * "IMAP4_SSL"

  * "IMAP4_stream"

  * "Internaldate2tuple()"

  * "Int2AP()"

  * "ParseFlags()"

  * "Time2Internaldate()"

  * IMAP4 Objects

    * "append()"

    * "authenticate()"

    * "check()"

    * "close()"

    * "copy()"

    * "create()"

    * "delete()"

    * "deleteacl()"

    * "enable()"

    * "expunge()"

    * "fetch()"

    * "getacl()"

    * "getannotation()"

    * "getquota()"

    * "getquotaroot()"

    * "list()"

    * "login()"

    * "login_cram_md5()"

    * "logout()"

    * "lsub()"

    * "myrights()"

    * "namespace()"

    * "noop()"

    * "open()"

    * "partial()"

    * "proxyauth()"

    * "read()"

    * "readline()"

    * "recent()"

    * "rename()"

    * "response()"

    * "search()"

    * "select()"

    * "send()"

    * "setacl()"

    * "setannotation()"

    * "setquota()"

    * "shutdown()"

    * "socket()"

    * "sort()"

    * "starttls()"

    * "status()"

    * "store()"

    * "subscribe()"

    * "thread()"

    * "uid()"

    * "unsubscribe()"

    * "unselect()"

    * "xatom()"

    * "PROTOCOL_VERSION"

    * "debug"

    * "utf8_enabled"

  * IMAP4 Example

* "smtplib" — SMTP protocol client

  * "SMTP"

  * "SMTP_SSL"

  * "LMTP"

  * "SMTPException"

  * "SMTPServerDisconnected"

  * "SMTPResponseException"

  * "SMTPSenderRefused"

  * "SMTPRecipientsRefused"

  * "SMTPDataError"

  * "SMTPConnectError"

  * "SMTPHeloError"

  * "SMTPNotSupportedError"

  * "SMTPAuthenticationError"

  * SMTP Objects

    * "set_debuglevel()"

    * "docmd()"

    * "connect()"

    * "helo()"

    * "ehlo()"

    * "ehlo_or_helo_if_needed()"

    * "has_extn()"

    * "verify()"

    * "login()"

    * "auth()"

    * "starttls()"

    * "sendmail()"

    * "send_message()"

    * "quit()"

  * SMTP Example

* "uuid" — UUID objects according to **RFC 4122**

  * "SafeUUID"

    * "safe"

    * "unsafe"

    * "unknown"

  * "UUID"

  * "bytes"

  * "bytes_le"

  * "fields"

  * "time_low"

  * "time_mid"

  * "time_hi_version"

  * "clock_seq_hi_variant"

  * "clock_seq_low"

  * "node"

  * "time"

  * "clock_seq"

  * "hex"

  * "int"

  * "urn"

  * "variant"

  * "version"

  * "is_safe"

  * "getnode()"

  * "uuid1()"

  * "uuid3()"

  * "uuid4()"

  * "uuid5()"

  * "NAMESPACE_DNS"

  * "NAMESPACE_URL"

  * "NAMESPACE_OID"

  * "NAMESPACE_X500"

  * "RESERVED_NCS"

  * "RFC_4122"

  * "RESERVED_MICROSOFT"

  * "RESERVED_FUTURE"

  * Command-Line Usage

  * Example

  * Command-Line Example

* "socketserver" — A framework for network servers

  * "TCPServer"

  * "UDPServer"

  * "UnixStreamServer"

  * "UnixDatagramServer"

  * Server Creation Notes

    * "ForkingMixIn"

    * "ThreadingMixIn"

      * "block_on_close"

      * "daemon_threads"

    * "ForkingTCPServer"

    * "ForkingUDPServer"

    * "ThreadingTCPServer"

    * "ThreadingUDPServer"

    * "ForkingUnixStreamServer"

    * "ForkingUnixDatagramServer"

    * "ThreadingUnixStreamServer"

    * "ThreadingUnixDatagramServer"

  * Server Objects

    * "BaseServer"

      * "fileno()"

      * "handle_request()"

      * "serve_forever()"

      * "service_actions()"

      * "shutdown()"

      * "server_close()"

      * "address_family"

      * "RequestHandlerClass"

      * "server_address"

      * "socket"

      * "allow_reuse_address"

      * "request_queue_size"

      * "socket_type"

      * "timeout"

      * "finish_request()"

      * "get_request()"

      * "handle_error()"

      * "handle_timeout()"

      * "process_request()"

      * "server_activate()"

      * "server_bind()"

      * "verify_request()"

  * Request Handler Objects

    * "BaseRequestHandler"

      * "setup()"

      * "handle()"

      * "finish()"

      * "request"

      * "client_address"

      * "server"

    * "StreamRequestHandler"

    * "DatagramRequestHandler"

      * "rfile"

      * "wfile"

  * Examples

    * "socketserver.TCPServer" Example

    * "socketserver.UDPServer" Example

    * Asynchronous Mixins

* "http.server" — HTTP servers

  * "HTTPServer"

  * "ThreadingHTTPServer"

  * "BaseHTTPRequestHandler"

    * "client_address"

    * "server"

    * "close_connection"

    * "requestline"

    * "command"

    * "path"

    * "request_version"

    * "headers"

    * "rfile"

    * "wfile"

    * "server_version"

    * "sys_version"

    * "error_message_format"

    * "error_content_type"

    * "protocol_version"

    * "MessageClass"

    * "responses"

    * "handle()"

    * "handle_one_request()"

    * "handle_expect_100()"

    * "send_error()"

    * "send_response()"

    * "send_header()"

    * "send_response_only()"

    * "end_headers()"

    * "flush_headers()"

    * "log_request()"

    * "log_error()"

    * "log_message()"

    * "version_string()"

    * "date_time_string()"

    * "log_date_time_string()"

    * "address_string()"

  * "SimpleHTTPRequestHandler"

    * "server_version"

    * "extensions_map"

    * "do_HEAD()"

    * "do_GET()"

  * "CGIHTTPRequestHandler"

    * "cgi_directories"

    * "do_POST()"

  * Security Considerations

* "http.cookies" — HTTP state management

  * "CookieError"

  * "BaseCookie"

  * "SimpleCookie"

  * Cookie Objects

    * "value_decode()"

    * "value_encode()"

    * "output()"

    * "js_output()"

    * "load()"

  * Morsel Objects

    * "Morsel"

      * "expires"

      * "path"

      * "comment"

      * "domain"

      * "secure"

      * "version"

      * "httponly"

      * "samesite"

    * "value"

    * "coded_value"

    * "key"

    * "set()"

    * "isReservedKey()"

    * "output()"

    * "js_output()"

    * "OutputString()"

    * "update()"

    * "copy()"

    * "setdefault()"

  * Example

* "http.cookiejar" — Cookie handling for HTTP clients

  * "LoadError"

  * "CookieJar"

  * "FileCookieJar"

  * "CookiePolicy"

  * "DefaultCookiePolicy"

  * "Cookie"

  * CookieJar and FileCookieJar Objects

    * "add_cookie_header()"

    * "extract_cookies()"

    * "set_policy()"

    * "make_cookies()"

    * "set_cookie_if_ok()"

    * "set_cookie()"

    * "clear()"

    * "clear_session_cookies()"

    * "save()"

    * "load()"

    * "revert()"

    * "filename"

    * "delayload"

  * FileCookieJar subclasses and co-operation with web browsers

    * "MozillaCookieJar"

    * "LWPCookieJar"

  * CookiePolicy Objects

    * "set_ok()"

    * "return_ok()"

    * "domain_return_ok()"

    * "path_return_ok()"

    * "netscape"

    * "rfc2965"

    * "hide_cookie2"

  * DefaultCookiePolicy Objects

    * "blocked_domains()"

    * "set_blocked_domains()"

    * "is_blocked()"

    * "allowed_domains()"

    * "set_allowed_domains()"

    * "is_not_allowed()"

    * "rfc2109_as_netscape"

    * "strict_domain"

    * "strict_rfc2965_unverifiable"

    * "strict_ns_unverifiable"

    * "strict_ns_domain"

    * "strict_ns_set_initial_dollar"

    * "strict_ns_set_path"

    * "DomainStrictNoDots"

    * "DomainStrictNonDomain"

    * "DomainRFC2965Match"

    * "DomainLiberal"

    * "DomainStrict"

  * Cookie Objects

    * "version"

    * "name"

    * "value"

    * "port"

    * "domain"

    * "path"

    * "secure"

    * "expires"

    * "discard"

    * "comment"

    * "comment_url"

    * "rfc2109"

    * "port_specified"

    * "domain_specified"

    * "domain_initial_dot"

    * "has_nonstandard_attr()"

    * "get_nonstandard_attr()"

    * "set_nonstandard_attr()"

    * "is_expired()"

  * Examples

* "xmlrpc" — XMLRPC server and client modules

* "xmlrpc.client" — XML-RPC client access

  * "ServerProxy"

  * ServerProxy Objects

    * "listMethods()"

    * "methodSignature()"

    * "methodHelp()"

  * DateTime Objects

    * "DateTime"

      * "decode()"

      * "encode()"

  * Binary Objects

    * "Binary"

      * "data"

      * "decode()"

      * "encode()"

  * Fault Objects

    * "Fault"

      * "faultCode"

      * "faultString"

  * ProtocolError Objects

    * "ProtocolError"

      * "url"

      * "errcode"

      * "errmsg"

      * "headers"

  * MultiCall Objects

    * "MultiCall"

  * Convenience Functions

    * "dumps()"

    * "loads()"

  * Example of Client Usage

  * Example of Client and Server Usage

* "xmlrpc.server" — Basic XML-RPC servers

  * "SimpleXMLRPCServer"

  * "CGIXMLRPCRequestHandler"

  * "SimpleXMLRPCRequestHandler"

  * SimpleXMLRPCServer Objects

    * "register_function()"

    * "register_instance()"

    * "register_introspection_functions()"

    * "register_multicall_functions()"

    * "rpc_paths"

    * SimpleXMLRPCServer Example

  * CGIXMLRPCRequestHandler

    * "register_function()"

    * "register_instance()"

    * "register_introspection_functions()"

    * "register_multicall_functions()"

    * "handle_request()"

  * Documenting XMLRPC server

    * "DocXMLRPCServer"

    * "DocCGIXMLRPCRequestHandler"

    * "DocXMLRPCRequestHandler"

  * DocXMLRPCServer Objects

    * "set_server_title()"

    * "set_server_name()"

    * "set_server_documentation()"

  * DocCGIXMLRPCRequestHandler

    * "set_server_title()"

    * "set_server_name()"

    * "set_server_documentation()"

* "ipaddress" — IPv4/IPv6 manipulation library

  * Convenience factory functions

    * "ip_address()"

    * "ip_network()"

    * "ip_interface()"

  * IP Addresses

    * Address objects

      * "IPv4Address"

        * "version"

        * "max_prefixlen"

        * "compressed"

        * "exploded"

        * "packed"

        * "reverse_pointer"

        * "is_multicast"

        * "is_private"

        * "is_global"

        * "is_unspecified"

        * "is_reserved"

        * "is_loopback"

        * "is_link_local"

      * "__format__()"

      * "IPv6Address"

        * "compressed"

        * "exploded"

        * "packed"

        * "reverse_pointer"

        * "version"

        * "max_prefixlen"

        * "is_multicast"

        * "is_private"

        * "is_global"

        * "is_unspecified"

        * "is_reserved"

        * "is_loopback"

        * "is_link_local"

        * "is_site_local"

        * "ipv4_mapped"

        * "scope_id"

        * "sixtofour"

        * "teredo"

      * "__format__()"

    * Conversion to Strings and Integers

    * Operators

      * Comparison operators

      * Arithmetic operators

  * IP Network definitions

    * Prefix, net mask and host mask

    * Network objects

      * "IPv4Network"

        * "version"

        * "max_prefixlen"

        * "is_multicast"

        * "is_private"

        * "is_unspecified"

        * "is_reserved"

        * "is_loopback"

        * "is_link_local"

        * "network_address"

        * "broadcast_address"

        * "hostmask"

        * "netmask"

        * "with_prefixlen"

        * "compressed"

        * "exploded"

        * "with_netmask"

        * "with_hostmask"

        * "num_addresses"

        * "prefixlen"

        * "hosts()"

        * "overlaps()"

        * "address_exclude()"

        * "subnets()"

        * "supernet()"

        * "subnet_of()"

        * "supernet_of()"

        * "compare_networks()"

      * "IPv6Network"

        * "version"

        * "max_prefixlen"

        * "is_multicast"

        * "is_private"

        * "is_unspecified"

        * "is_reserved"

        * "is_loopback"

        * "is_link_local"

        * "network_address"

        * "broadcast_address"

        * "hostmask"

        * "netmask"

        * "with_prefixlen"

        * "compressed"

        * "exploded"

        * "with_netmask"

        * "with_hostmask"

        * "num_addresses"

        * "prefixlen"

        * "hosts()"

        * "overlaps()"

        * "address_exclude()"

        * "subnets()"

        * "supernet()"

        * "subnet_of()"

        * "supernet_of()"

        * "compare_networks()"

        * "is_site_local"

    * Operators

      * Logical operators

      * Iteration

      * Networks as containers of addresses

  * Interface objects

    * "IPv4Interface"

      * "ip"

      * "network"

      * "with_prefixlen"

      * "with_netmask"

      * "with_hostmask"

    * "IPv6Interface"

      * "ip"

      * "network"

      * "with_prefixlen"

      * "with_netmask"

      * "with_hostmask"

    * Operators

      * Logical operators

  * Other Module Level Functions

    * "v4_int_to_packed()"

    * "v6_int_to_packed()"

    * "summarize_address_range()"

    * "collapse_addresses()"

    * "get_mixed_type_key()"

  * Custom Exceptions

    * "AddressValueError"

    * "NetmaskValueError"
