Created
July 4, 2017 03:04
-
-
Save anonymous/5c3fbd0cee301973f9c26002dc4854da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat test.py | |
#!/usr/bin/env python3 | |
from http import HTTPStatus | |
from urllib.request import Request, urlopen | |
BASE = 'https://httpbin.org/status/' | |
for code in HTTPStatus: | |
code = int(code) | |
req = Request(BASE + str(code)) | |
try: | |
resp = urlopen(req) | |
# print("{} OK: {}".format(code, resp)) | |
except Exception as ex: | |
print("{} exception: {}".format(code, ex)) | |
$ python3 -V | |
Python 3.6.1 | |
$ python3 test.py | |
100 exception: HTTP Error 503: Service Unavailable | |
101 exception: HTTP Error 101: SWITCHING PROTOCOLS | |
102 exception: HTTP Error 102: PROCESSING | |
300 exception: HTTP Error 300: MULTIPLE CHOICES | |
304 exception: HTTP Error 304: NOT MODIFIED | |
305 exception: HTTP Error 305: USE PROXY | |
308 exception: HTTP Error 308: UNKNOWN | |
400 exception: HTTP Error 400: BAD REQUEST | |
401 exception: HTTP Error 401: UNAUTHORIZED | |
402 exception: HTTP Error 402: PAYMENT REQUIRED | |
403 exception: HTTP Error 403: FORBIDDEN | |
404 exception: HTTP Error 404: NOT FOUND | |
405 exception: HTTP Error 405: METHOD NOT ALLOWED | |
406 exception: HTTP Error 406: NOT ACCEPTABLE | |
407 exception: HTTP Error 407: PROXY AUTHENTICATION REQUIRED | |
408 exception: HTTP Error 408: REQUEST TIMEOUT | |
409 exception: HTTP Error 409: CONFLICT | |
410 exception: HTTP Error 410: GONE | |
411 exception: HTTP Error 411: LENGTH REQUIRED | |
412 exception: HTTP Error 412: PRECONDITION FAILED | |
413 exception: HTTP Error 413: REQUEST ENTITY TOO LARGE | |
414 exception: HTTP Error 414: REQUEST URI TOO LONG | |
415 exception: HTTP Error 415: UNSUPPORTED MEDIA TYPE | |
416 exception: HTTP Error 416: REQUESTED RANGE NOT SATISFIABLE | |
417 exception: HTTP Error 417: EXPECTATION FAILED | |
422 exception: HTTP Error 422: UNPROCESSABLE ENTITY | |
423 exception: HTTP Error 423: LOCKED | |
424 exception: HTTP Error 424: FAILED DEPENDENCY | |
426 exception: HTTP Error 426: UPGRADE REQUIRED | |
428 exception: HTTP Error 428: PRECONDITION REQUIRED | |
429 exception: HTTP Error 429: TOO MANY REQUESTS | |
431 exception: HTTP Error 431: REQUEST HEADER FIELDS TOO LARGE | |
500 exception: HTTP Error 500: INTERNAL SERVER ERROR | |
501 exception: HTTP Error 501: NOT IMPLEMENTED | |
502 exception: HTTP Error 502: BAD GATEWAY | |
503 exception: HTTP Error 503: SERVICE UNAVAILABLE | |
504 exception: HTTP Error 504: GATEWAY TIMEOUT | |
505 exception: HTTP Error 505: HTTP VERSION NOT SUPPORTED | |
506 exception: HTTP Error 506: UNKNOWN | |
507 exception: HTTP Error 507: INSUFFICIENT STORAGE | |
508 exception: HTTP Error 508: UNKNOWN | |
510 exception: HTTP Error 510: NOT EXTENDED | |
511 exception: HTTP Error 511: UNKNOWN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment