rockiol rockiol
rockiol rockiol

Reputation: 68

Showing allowed HTTP methods

I want to get the allowed HTTP methods with the HTTP OPTIONS method, like this:

telnet site.com 80
OPTIONS / HTTP/1.0

Result:

HTTP/1.1 200 OK
Date: Sun, 14 Oct 2012 21:04:39 GMT
Server: Apache
Allow: GET,HEAD,POST,OPTIONS
Content-Length: 0
Connection: close
Content-Type: text/html

How can I do this using Python libs?

Upvotes: 3

Views: 2720

Answers (1)

utapyngo
utapyngo

Reputation: 7146

import httplib
conn = httplib.HTTPConnection('w3.com')
conn.request('OPTIONS', '/')
response = conn.getresponse()
print response.getheader('allow')

The result is

OPTIONS, TRACE, GET, HEAD, POST

Upvotes: 2

Related Questions