thk thk Κυρ. 18 Μαϊος. 2008 18:02 tags προγραμματισμός , python 1 views
Since image files are served from the python handlers in madpy
(notice that img src is in the form /somepath/path/image or /somepath/path/thumbnail and so on..)
, I needed a way to view their http headers.
I tried (and maybe still trying) to debug , caching , last-modified http header e.t.c.
I am trying to work with the last-modified http header to achieve image caching in the browser.
So I needed a way to view the http headers of a request. I believe the web developer firefox plugin has this functionality with plain pages but not with files.
Anyway I ended up writing this python script that retrieves and shows http headers of an http request and of  course works with files as well.

def headers(uri):
    import urllib2
    request = urllib2.Request(uri)
    opener = urllib2.build_opener()
    firstdatastream = opener.open(request)
    headersDict = firstdatastream.headers.dict
    return headersDict

if __name__ == '__main__':
    import sys
    if len(sys.argv) > 1:
        uri = sys.argv[1]
    if not uri:

        uri = raw_input("enter url:")
    print uri
    print str(headers(uri))

θυμήσου με
Ελιές πουλι
2023-11-14 21:13
αν δεν 2
2023-10-14 00:32
αν δεν
2023-10-13 21:42
2023-10-10 01:02