인터넷 프로토콜과 지원¶
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 환경 유틸리티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 types for static type checking- 예제
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 객체
- OpenerDirector 객체
- BaseHandler 객체
- HTTPRedirectHandler 객체
- HTTPCookieProcessor 객체
- ProxyHandler 객체
- HTTPPasswordMgr 객체
- HTTPPasswordMgrWithPriorAuth 객체
- AbstractBasicAuthHandler 객체
- HTTPBasicAuthHandler 객체
- ProxyBasicAuthHandler 객체
- AbstractDigestAuthHandler 객체
- HTTPDigestAuthHandler 객체
- ProxyDigestAuthHandler 객체
- HTTPHandler 객체
- HTTPSHandler 객체
- FileHandler 객체
- DataHandler 객체
- FTPHandler 객체
- CacheFTPHandler 객체
- UnknownHandler 객체
- HTTPErrorProcessor 객체
- 예
- 레거시 인터페이스
urllib.request
제약 사항
urllib.response
— urllib가 사용하는 응답 클래스urllib.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 객체
- HTTPResponse 객체
- 예
- HTTPMessage 객체
ftplib
— FTP protocol clientpoplib
— POP3 protocol clientimaplib
— IMAP4 protocol clientIMAP4
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 protocol clientuuid
— UUID objects according to RFC 9562SafeUUID
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()
uuid8()
NAMESPACE_DNS
NAMESPACE_URL
NAMESPACE_OID
NAMESPACE_X500
RESERVED_NCS
RFC_4122
RESERVED_MICROSOFT
RESERVED_FUTURE
- Command-Line Usage
- 예제
- Command-Line Example
socketserver
— A framework for network serversTCPServer
UDPServer
UnixStreamServer
UnixDatagramServer
- 서버 생성 노트
- 서버 객체
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()
- 요청 처리기 객체
- 예
http.server
— HTTP serversHTTPServer
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
- Security Considerations
http.cookies
— HTTP state managementhttp.cookiejar
— Cookie handling for HTTP clientsLoadError
CookieJar
FileCookieJar
CookiePolicy
DefaultCookiePolicy
Cookie
- CookieJar와 FileCookieJar 객체
- FileCookieJar 서브 클래스와 웹 브라우저와의 협력
- 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 server and client modulesxmlrpc.client
— XML-RPC client accessxmlrpc.server
— Basic XML-RPC serversipaddress
— IPv4/IPv6 manipulation library- 편의 팩토리 함수
- IP 주소
- IP 네트워크 정의
- 접두사, 네트 마스크 및 호스트 마스크
- 네트워크 객체
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
- 연산자
- 인터페이스 객체
- 다른 모듈 수준 함수
- 맞춤 예외