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 controllerwsgiref
— WSGI Utilities and Reference Implementationwsgiref.util
– WSGI environment utilitieswsgiref.headers
– WSGI response header toolswsgiref.simple_server
– a simple WSGI HTTP serverwsgiref.validate
— WSGI conformance checkerwsgiref.handlers
– server/gateway base classesCGIHandler
IISCGIHandler
BaseCGIHandler
SimpleHandler
BaseHandler
BaseHandler.run()
BaseHandler._write()
BaseHandler._flush()
BaseHandler.get_stdin()
BaseHandler.get_stderr()
BaseHandler.add_cgi_vars()
BaseHandler.wsgi_multithread
BaseHandler.wsgi_multiprocess
BaseHandler.wsgi_run_once
BaseHandler.os_environ
BaseHandler.server_software
BaseHandler.get_scheme()
BaseHandler.setup_environ()
BaseHandler.log_exception()
BaseHandler.traceback_limit
BaseHandler.error_output()
BaseHandler.error_status
BaseHandler.error_headers
BaseHandler.error_body
BaseHandler.wsgi_file_wrapper
BaseHandler.sendfile()
BaseHandler.origin_server
BaseHandler.http_version
read_environ()
wsgiref.types
– WSGI types for static type checking- Examples
urllib
— URL handling modulesurllib.request
— Extensible library for opening URLsurlopen()
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
Request.full_url
Request.type
Request.host
Request.origin_req_host
Request.selector
Request.data
Request.unverifiable
Request.method
Request.get_method()
Request.add_header()
Request.add_unredirected_header()
Request.has_header()
Request.remove_header()
Request.get_full_url()
Request.set_proxy()
Request.get_header()
Request.header_items()
- OpenerDirector Objects
- BaseHandler Objects
- HTTPRedirectHandler Objects
- HTTPCookieProcessor Objects
- ProxyHandler Objects
- HTTPPasswordMgr Objects
- HTTPPasswordMgrWithPriorAuth Objects
- AbstractBasicAuthHandler Objects
- HTTPBasicAuthHandler Objects
- ProxyBasicAuthHandler Objects
- AbstractDigestAuthHandler Objects
- HTTPDigestAuthHandler Objects
- ProxyDigestAuthHandler Objects
- HTTPHandler Objects
- HTTPSHandler Objects
- FileHandler Objects
- DataHandler Objects
- FTPHandler Objects
- CacheFTPHandler Objects
- UnknownHandler Objects
- HTTPErrorProcessor Objects
- Examples
- Legacy interface
urllib.request
Restrictions
urllib.response
— Response classes used by urlliburllib.parse
— Parse URLs into componentsurllib.error
— Exception classes raised by urllib.requesturllib.robotparser
— Parser for robots.txthttp
— HTTP moduleshttp.client
— HTTP protocol clientHTTPConnection
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
- HTTPResponse Objects
HTTPResponse.read()
HTTPResponse.readinto()
HTTPResponse.getheader()
HTTPResponse.getheaders()
HTTPResponse.fileno()
HTTPResponse.msg
HTTPResponse.version
HTTPResponse.url
HTTPResponse.headers
HTTPResponse.status
HTTPResponse.reason
HTTPResponse.debuglevel
HTTPResponse.closed
HTTPResponse.geturl()
HTTPResponse.info()
HTTPResponse.getstatus()
- Examples
- HTTPMessage Objects
ftplib
— FTP protocol clientFTP
FTP_TLS
error_reply
error_temp
error_perm
error_proto
all_errors
- FTP Objects
FTP.set_debuglevel()
FTP.connect()
FTP.getwelcome()
FTP.login()
FTP.abort()
FTP.sendcmd()
FTP.voidcmd()
FTP.retrbinary()
FTP.retrlines()
FTP.set_pasv()
FTP.storbinary()
FTP.storlines()
FTP.transfercmd()
FTP.ntransfercmd()
FTP.mlsd()
FTP.nlst()
FTP.dir()
FTP.rename()
FTP.delete()
FTP.cwd()
FTP.mkd()
FTP.pwd()
FTP.rmd()
FTP.size()
FTP.quit()
FTP.close()
- FTP_TLS Objects
poplib
— POP3 protocol clientimaplib
— IMAP4 protocol clientIMAP4
IMAP4_SSL
IMAP4_stream
Internaldate2tuple()
Int2AP()
ParseFlags()
Time2Internaldate()
- IMAP4 Objects
IMAP4.append()
IMAP4.authenticate()
IMAP4.check()
IMAP4.close()
IMAP4.copy()
IMAP4.create()
IMAP4.delete()
IMAP4.deleteacl()
IMAP4.enable()
IMAP4.expunge()
IMAP4.fetch()
IMAP4.getacl()
IMAP4.getannotation()
IMAP4.getquota()
IMAP4.getquotaroot()
IMAP4.list()
IMAP4.login()
IMAP4.login_cram_md5()
IMAP4.logout()
IMAP4.lsub()
IMAP4.myrights()
IMAP4.namespace()
IMAP4.noop()
IMAP4.open()
IMAP4.partial()
IMAP4.proxyauth()
IMAP4.read()
IMAP4.readline()
IMAP4.recent()
IMAP4.rename()
IMAP4.response()
IMAP4.search()
IMAP4.select()
IMAP4.send()
IMAP4.setacl()
IMAP4.setannotation()
IMAP4.setquota()
IMAP4.shutdown()
IMAP4.socket()
IMAP4.sort()
IMAP4.starttls()
IMAP4.status()
IMAP4.store()
IMAP4.subscribe()
IMAP4.thread()
IMAP4.uid()
IMAP4.unsubscribe()
IMAP4.unselect()
IMAP4.xatom()
IMAP4.PROTOCOL_VERSION
IMAP4.debug
IMAP4.utf8_enabled
- IMAP4 Example
smtplib
— SMTP protocol clientuuid
— UUID objects according to RFC 4122socketserver
— A framework for network serversTCPServer
UDPServer
UnixStreamServer
UnixDatagramServer
- Server Creation Notes
- Server Objects
BaseServer
BaseServer.fileno()
BaseServer.handle_request()
BaseServer.serve_forever()
BaseServer.service_actions()
BaseServer.shutdown()
BaseServer.server_close()
BaseServer.address_family
BaseServer.RequestHandlerClass
BaseServer.server_address
BaseServer.socket
BaseServer.allow_reuse_address
BaseServer.request_queue_size
BaseServer.socket_type
BaseServer.timeout
BaseServer.finish_request()
BaseServer.get_request()
BaseServer.handle_error()
BaseServer.handle_timeout()
BaseServer.process_request()
BaseServer.server_activate()
BaseServer.server_bind()
BaseServer.verify_request()
- Request Handler Objects
- Examples
http.server
— HTTP serversHTTPServer
ThreadingHTTPServer
BaseHTTPRequestHandler
BaseHTTPRequestHandler.client_address
BaseHTTPRequestHandler.server
BaseHTTPRequestHandler.close_connection
BaseHTTPRequestHandler.requestline
BaseHTTPRequestHandler.command
BaseHTTPRequestHandler.path
BaseHTTPRequestHandler.request_version
BaseHTTPRequestHandler.headers
BaseHTTPRequestHandler.rfile
BaseHTTPRequestHandler.wfile
BaseHTTPRequestHandler.server_version
BaseHTTPRequestHandler.sys_version
BaseHTTPRequestHandler.error_message_format
BaseHTTPRequestHandler.error_content_type
BaseHTTPRequestHandler.protocol_version
BaseHTTPRequestHandler.MessageClass
BaseHTTPRequestHandler.responses
BaseHTTPRequestHandler.handle()
BaseHTTPRequestHandler.handle_one_request()
BaseHTTPRequestHandler.handle_expect_100()
BaseHTTPRequestHandler.send_error()
BaseHTTPRequestHandler.send_response()
BaseHTTPRequestHandler.send_header()
BaseHTTPRequestHandler.send_response_only()
BaseHTTPRequestHandler.end_headers()
BaseHTTPRequestHandler.flush_headers()
BaseHTTPRequestHandler.log_request()
BaseHTTPRequestHandler.log_error()
BaseHTTPRequestHandler.log_message()
BaseHTTPRequestHandler.version_string()
BaseHTTPRequestHandler.date_time_string()
BaseHTTPRequestHandler.log_date_time_string()
BaseHTTPRequestHandler.address_string()
SimpleHTTPRequestHandler
CGIHTTPRequestHandler
- Security Considerations
http.cookies
— HTTP state managementhttp.cookiejar
— Cookie handling for HTTP clientsLoadError
CookieJar
FileCookieJar
CookiePolicy
DefaultCookiePolicy
Cookie
- CookieJar and FileCookieJar Objects
CookieJar.add_cookie_header()
CookieJar.extract_cookies()
CookieJar.set_policy()
CookieJar.make_cookies()
CookieJar.set_cookie_if_ok()
CookieJar.set_cookie()
CookieJar.clear()
CookieJar.clear_session_cookies()
FileCookieJar.save()
FileCookieJar.load()
FileCookieJar.revert()
FileCookieJar.filename
FileCookieJar.delayload
- FileCookieJar subclasses and co-operation with web browsers
- CookiePolicy Objects
- DefaultCookiePolicy Objects
DefaultCookiePolicy.blocked_domains()
DefaultCookiePolicy.set_blocked_domains()
DefaultCookiePolicy.is_blocked()
DefaultCookiePolicy.allowed_domains()
DefaultCookiePolicy.set_allowed_domains()
DefaultCookiePolicy.is_not_allowed()
DefaultCookiePolicy.rfc2109_as_netscape
DefaultCookiePolicy.strict_domain
DefaultCookiePolicy.strict_rfc2965_unverifiable
DefaultCookiePolicy.strict_ns_unverifiable
DefaultCookiePolicy.strict_ns_domain
DefaultCookiePolicy.strict_ns_set_initial_dollar
DefaultCookiePolicy.strict_ns_set_path
DefaultCookiePolicy.DomainStrictNoDots
DefaultCookiePolicy.DomainStrictNonDomain
DefaultCookiePolicy.DomainRFC2965Match
DefaultCookiePolicy.DomainLiberal
DefaultCookiePolicy.DomainStrict
- Cookie Objects
Cookie.version
Cookie.name
Cookie.value
Cookie.port
Cookie.path
Cookie.secure
Cookie.expires
Cookie.discard
Cookie.comment
Cookie.comment_url
Cookie.rfc2109
Cookie.port_specified
Cookie.domain_specified
Cookie.domain_initial_dot
Cookie.has_nonstandard_attr()
Cookie.get_nonstandard_attr()
Cookie.set_nonstandard_attr()
Cookie.is_expired()
- Examples
xmlrpc
— XMLRPC server and client modulesxmlrpc.client
— XML-RPC client accessxmlrpc.server
— Basic XML-RPC serversipaddress
— IPv4/IPv6 manipulation library- Convenience factory functions
- IP Addresses
- Address objects
IPv4Address
IPv4Address.version
IPv4Address.max_prefixlen
IPv4Address.compressed
IPv4Address.exploded
IPv4Address.packed
IPv4Address.reverse_pointer
IPv4Address.is_multicast
IPv4Address.is_private
IPv4Address.is_global
IPv4Address.is_unspecified
IPv4Address.is_reserved
IPv4Address.is_loopback
IPv4Address.is_link_local
IPv4Address.__format__()
IPv6Address
IPv6Address.compressed
IPv6Address.exploded
IPv6Address.packed
IPv6Address.reverse_pointer
IPv6Address.version
IPv6Address.max_prefixlen
IPv6Address.is_multicast
IPv6Address.is_private
IPv6Address.is_global
IPv6Address.is_unspecified
IPv6Address.is_reserved
IPv6Address.is_loopback
IPv6Address.is_link_local
IPv6Address.is_site_local
IPv6Address.ipv4_mapped
IPv6Address.scope_id
IPv6Address.sixtofour
IPv6Address.teredo
IPv6Address.__format__()
- Conversion to Strings and Integers
- Operators
- Address objects
- IP Network definitions
- Prefix, net mask and host mask
- Network objects
IPv4Network
IPv4Network.version
IPv4Network.max_prefixlen
IPv4Network.is_multicast
IPv4Network.is_private
IPv4Network.is_unspecified
IPv4Network.is_reserved
IPv4Network.is_loopback
IPv4Network.is_link_local
IPv4Network.network_address
IPv4Network.broadcast_address
IPv4Network.hostmask
IPv4Network.netmask
IPv4Network.with_prefixlen
IPv4Network.compressed
IPv4Network.exploded
IPv4Network.with_netmask
IPv4Network.with_hostmask
IPv4Network.num_addresses
IPv4Network.prefixlen
IPv4Network.hosts()
IPv4Network.overlaps()
IPv4Network.address_exclude()
IPv4Network.subnets()
IPv4Network.supernet()
IPv4Network.subnet_of()
IPv4Network.supernet_of()
IPv4Network.compare_networks()
IPv6Network
IPv6Network.version
IPv6Network.max_prefixlen
IPv6Network.is_multicast
IPv6Network.is_private
IPv6Network.is_unspecified
IPv6Network.is_reserved
IPv6Network.is_loopback
IPv6Network.is_link_local
IPv6Network.network_address
IPv6Network.broadcast_address
IPv6Network.hostmask
IPv6Network.netmask
IPv6Network.with_prefixlen
IPv6Network.compressed
IPv6Network.exploded
IPv6Network.with_netmask
IPv6Network.with_hostmask
IPv6Network.num_addresses
IPv6Network.prefixlen
IPv6Network.hosts()
IPv6Network.overlaps()
IPv6Network.address_exclude()
IPv6Network.subnets()
IPv6Network.supernet()
IPv6Network.subnet_of()
IPv6Network.supernet_of()
IPv6Network.compare_networks()
IPv6Network.is_site_local
- Operators
- Interface objects
- Other Module Level Functions
- Custom Exceptions