# encoding:utf-8
# baseic usage of requests.sessions
import requests
from requests import sessions
r = requests.Request('GET', 'http://172.21.2.3:8009/ad09')
print r.cookies
s = sessions.Session()
# 要获取带有状态的PrepareRequest 对象
# Session.prepare_request() 取代 Request.prepare()
# p = s.prepare_request(r)
# print(dir(p))
# resp = s.send(p,
# timeout=30
# )
# the session.request() will prepare the Reuest<Request> object and send it then get the response
# resp=s.request('GET', 'http://172.21.2.3:8009/ad09')
# the session.get() call the request
# resp=s.get('http://172.21.2.3:8009/ad09')
# resp=s.options('http://172.21.2.3:8009/ad09')
# r = requests.Request('GET', 'http://172.21.2.3:8009/ad09')
# p = r.prepare()
# resp =s.send(p)
# print(resp.status_code,"====")
# s.get("http://172.21.2.3:8009/ad09")
# or as context manager
# with sessions.Session() as s:
# s.get("http://httpbin.org/get")
import pickle
s = sessions.Session()
att=pickle.dumps(s)
print type(att),"="
attr=pickle.loads(att)
print attr
print type(attr)