Skip to content

Test HTTP Methods

2016-12-20 20:57:09

Test HTTP Methods

import urllib.request
import urllib.parse

http_methods = ['HEAD', 'GET', 'POST', 'OPTIONS', 'TRACE']

page_url = 'https://www.owasp.org/index.php/Test_HTTP_Methods_(OTG-CONFIG-006)'

for _method in http_methods:
    print("------ Method test: " + _method + " ------")
    try:
        req = urllib.request.Request(
                page_url,
                method=_method
        )

        response = urllib.request.urlopen(req)

        response_headers = response.getheaders()
        for header in response_headers:
            print(header)

    except:
        print('Error')