Skip to content
Advertisement

Tag: http

How do I catch a specific HTTP error in Python?

I have but what I end up is catching any kind of HTTP error. I want to catch only if the specified webpage doesn’t exist (404?). Answer Python 3 Python 2 Just catch HTTPError, handle it, and if it’s not Error 404, simply use raise to re-raise the exception. See the Python tutorial. Here is a complete example for Python

How do I debug a HTTP 502 error?

I have a Python Tornado server sitting behind a nginx frontend. Every now and then, but not every time, I get a 502 error. I look in the nginx access log and I see this: and in the error log: I don’t think any errors show up in the Tornado log. How would you go about debugging this? Is there

Python HTTP server that supports chunked encoding?

I’m looking for a well-supported multithreaded Python HTTP server that supports chunked encoding replies. (I.e. “Transfer-Encoding: chunked” on responses). What’s the best HTTP server base to start with for this purpose? Answer Twisted supports chunked transfer encoding (API link) (see also the API doc for HTTPChannel). There are a number of production-grade projects using Twisted (for example, Apple uses it

Advertisement