網路協定 (Internet protocols) 及支援¶
這個章節講述的模組實作了網路協定及相關技術的支援;他們全都是用 Python 實作的。這裡的大多數模組都需要相依於系統的模組 socket
,目前普遍的平台都支援該模組。 以下為概述:
webbrowser
--- 方便的網頁瀏覽器控制器wsgiref
--- WSGI 工具與參考實作wsgiref.util
-- WSGI 環境工具wsgiref.headers
-- WSGI 回應標頭工具wsgiref.simple_server
-- 一個簡單的 WSGI HTTP 伺服器wsgiref.validate
--- WSGI 符合性檢查wsgiref.handlers
-- 伺服器 / 閘道基本類別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 型別- 範例
urllib
--- URL 處理模組urllib.request
--- 用來開啟 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 物件
- OpenerDirector 物件
- BaseHandler 物件
- HTTPRedirectHandler 物件
- HTTPCookieProcessor 物件
- ProxyHandler 物件
- HTTPPasswordMgr 物件
- HTTPPasswordMgrWithPriorAuth 物件
- AbstractBasicAuthHandler 物件
- HTTPBasicAuthHandler 物件
- ProxyBasicAuthHandler 物件
- AbstractDigestAuthHandler 物件
- HTTPDigestAuthHandler 物件
- ProxyDigestAuthHandler 物件
- HTTPHandler 物件
- HTTPSHandler 物件
- FileHandler 物件
- DataHandler 物件
- FTPHandler 物件
- CacheFTPHandler 物件
- UnknownHandler 物件
- HTTPErrorProcessor 物件
- 範例
- Legacy interface
urllib.request
Restrictions
urllib.response
--- Response classes used by urlliburllib.parse
--- 將 URL 剖析成元件urllib.error
--- urllib.request 引發的例外類別urllib.robotparser
--- robots.txt 的剖析器http
--- HTTP 模組http.client
--- HTTP 協定用戶端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 物件
- HTTPResponse 物件
- 範例
- HTTPMessage 物件
ftplib
--- FTP 協定用戶端poplib
--- POP3 協定用戶端imaplib
--- IMAP4 協定客戶端IMAP4
error
abort
readonly
IMAP4_SSL
IMAP4_stream
Internaldate2tuple()
Int2AP()
ParseFlags()
Time2Internaldate()
- IMAP4 物件
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 範例
smtplib
--- SMTP 協定用戶端uuid
--- RFC 4122 定義的 UUID 物件SafeUUID
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
- 命令列的用法
- 範例
- 命令列的範例
socketserver
--- 用於網路伺服器的框架TCPServer
UDPServer
UnixStreamServer
UnixDatagramServer
- Server Creation Notes
- 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
- 範例
http.server
— HTTP 伺服器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
CGIHTTPRequestHandler
- 安全性注意事項
http.cookies
--- HTTP 狀態管理http.cookiejar
--- HTTP 客戶端的 Cookie 處理LoadError
CookieJar
FileCookieJar
CookiePolicy
DefaultCookiePolicy
Cookie
- CookieJar 與 FileCookieJar 物件
- FileCookieJar subclasses and co-operation with web browsers
- CookiePolicy 物件
- DefaultCookiePolicy 物件
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 物件
- 範例
xmlrpc
--- XMLRPC 伺服器與用戶模組xmlrpc.client
--- XML-RPC 客戶端存取xmlrpc.server
--- 基本 XML-RPC 伺服器ipaddress
--- IPv4/IPv6 操作函式庫- Convenience factory functions
- IP Addresses
- 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
- 運算子
- Interface objects
- Other Module Level Functions
- Custom Exceptions