<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 基本的登陆
Step1:  sending cookie
Step2:  Re-direction
302 means the URL has been redirected to some other location. We could use allow_redirects=False to disable this feature.
Step3:  time out
Step4:  session
session can persist cookies across requests
Step5:  session can be overriden
Step6:  这里的req是server返回的response 
当requests.get()或者session.get()，首先发生的事情是构造了一个request，这个request将被发送个server，同时req里也将保存这个request
接下来req就接收server返回的response
<ASSISTANT_TASK:>
Python Code:
url='http://httpbin.org'
req=requests.get(url+'/basic-auth/user/passwd',auth=('user','passwd'))
print(req.text)
print(req.url)
print(req.status_code)
import json
payload={'some':'data'}
headers={'Content-Type':'application/json','Authorization':'some token'}
req=requests.post(url+'/post',data=json.dumps(payload),headers=headers)
print(req.text)
req=requests.post(url+'/post',data=payload)
print(req.text)
files={'file':open('dump.txt','rb')}
req=requests.post(url+'/post',files=files)
print(req.text)
print(req.status_code)
req.status_code==requests.codes.ok
print(req.headers)
req.headers['content-type']
Explanation: 基本的登陆
End of explanation
cookies={}
cookies['cookie']='cookie-value'
req=requests.get(url+'/cookies',cookies=cookies)
print(req.text)
Explanation: sending cookie
End of explanation
req=requests.head('http://www.google.com',allow_redirects=True)
print(req.url)
req.history
req=requests.head('http://www.google.com',allow_redirects=False)
print(req.text)
Explanation: Re-direction
302 means the URL has been redirected to some other location. We could use allow_redirects=False to disable this feature.
End of explanation
try:
    req=requests.get('http://google.com',timeout=0.03)
except BaseException as e:
    print("It is exceeding timeout")
    print(str(e))
Explanation: time out
End of explanation
import requests
session=requests.Session()
session.headers.update(headers)
session.data='some data here'
session.params={'key1':'value1','key2':'value2'}
session.auth=('user','passwd')
req=session.get(url+'/basic-auth/user/passwd')
print(req.text)
req=session.get(url+'/get')
print(req.text)
req=session.post(url+'/post',data='some data here')
print(req.text)
Explanation: session
session can persist cookies across requests
End of explanation
req=session.get(url+'/get',headers={'Content-Type':'application','User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3'})
print(req.text)
Explanation: session can be overriden
End of explanation
print(req.request)
print(req.request.headers)
print(req.request.body)
print(req.headers)
print(req.text)
Explanation: 这里的req是server返回的response 
当requests.get()或者session.get()，首先发生的事情是构造了一个request，这个request将被发送个server，同时req里也将保存这个request
接下来req就接收server返回的response
End of explanation
<END_TASK>