しゃある通信

#23-02 [python]How to send HTTP/1.0 request via requests

import requests

try:            # python2
    import httplib as via
except:         # python3
   import http.client as via

via.HTTPConnection._http_vsn = 10
via.HTTPConnection._http_vsn_str = 'HTTP/1.0'

requests.head('http://localhost/')
access.log
127.0.0.1 - - [23/Jul/2013:17:57:00 +0900] "HEAD / HTTP/1.0" 200 - "-" "python-requests/1.2.3 CPython/2.6.6 Linux/2.6.32-358.2.1.el6.x86_64"
127.0.0.1 - - [23/Jul/2013:17:57:03 +0900] "HEAD / HTTP/1.0" 200 - "-" "python-requests/1.2.3 CPython/3.3.2 Linux/2.6.32-358.2.1.el6.x86_64"



マクロミルへ登録

© 2013 Kazuya 'Sharl' Masuda
(C)Willoo Entertainment Inc. (C)Konami Digital Entertainment 株式会社ウィローエンターテイメント及び株式会社コナミデジタルエンタテインメントの著作権を侵害する行為は禁止されています。 0.004131 cached