コード。
import httplib
PATH = '/image?format=png&gnubgid=4HPwATDgc%2FABMA%3AMAAAAAAAAAAA&height=300&width=400&css=minimal'
HOST = 'image.backgammonbase.com'
ADDR = '192.168.2.64'
conn = httplib.HTTPConnection(ADDR)
conn.request("GET", PATH, headers={'host':HOST})
r = conn.getresponse()
print r.status
print r.getheaders()
etag = r.getheader('etag')
print etag
conn.close()
conn = httplib.HTTPConnection(ADDR)
conn.request("GET", PATH, headers={'host':HOST, 'If-None-Match':etag})
r = conn.getresponse()
print r.status
print r.getheaders()
conn.close()
実行結果
[nori@asama]~/Desktop/study/python/httplib% python test.py
200
[('content-length', '17877'), ('age', '102'), ('expires', 'Thu, 21 May 2009 01:39:27 GMT'), ('server', 'Apache/2.2.3 (CentOS) mod_python/3.2.8 Python/2.4.3 DAV/2 SVN/1.6.2 mod_wsgi/2.1-BRANCH'), ('etag', 'code:6bf600612d854254f2d17b68682de576620b5257+css:c484f9e5d8c595e9c0d36f7889d651e21f06e4f7'), ('cache-control', 'public'), ('date', 'Thu, 21 May 2009 00:41:09 GMT'), ('content-type', 'image/png')]
code:6bf600612d854254f2d17b68682de576620b5257+css:c484f9e5d8c595e9c0d36f7889d651e21f06e4f7
304
[('date', 'Thu, 21 May 2009 00:41:09 GMT'), ('cache-control', 'public'), ('etag', 'code:6bf600612d854254f2d17b68682de576620b5257+css:c484f9e5d8c595e9c0d36f7889d651e21f06e4f7'), ('expires', 'Thu, 21 May 2009 01:39:27 GMT'), ('server', 'Apache/2.2.3 (CentOS) mod_python/3.2.8 Python/2.4.3 DAV/2 SVN/1.6.2 mod_wsgi/2.1-BRANCH')]
ヘッダをつけ間違えたかな?
0 件のコメント:
コメントを投稿