Replies: 2 comments
-
I made a small debug Python server: from http.server import BaseHTTPRequestHandler, HTTPServer
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/nothing':
self.send_response(200)
self.end_headers()
elif self.path == '/nothing_cl0':
self.send_response(200)
self.send_header('Content-Length', '0')
self.end_headers()
elif self.path == '/nothing_cl1':
self.send_response(200)
self.send_header('Content-Length', '1')
self.end_headers()
def run(server_class=HTTPServer, handler_class=SimpleHTTPRequestHandler, port=8000):
server_address = ('', port)
httpd = server_class(server_address, handler_class)
print(f'Starting httpd on port {port}...')
httpd.serve_forever()
if __name__ == '__main__':
run() And check it with (there will be some errors because httpx tries https first):
With |
Beta Was this translation helpful? Give feedback.
0 replies
-
Was moved to #1629 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I've been using httpx for quite a long time, and it's a really great project! Right now I'm struggling a bit to match empty response bodies. It looks to me that there's no DSL variable that I can use to get the actual length of the response body?
As far as I understand,
content_length
just takesContent-Length
from response headers, and it's not defined if there's no such header present (I know that websites shouldn't respond like this, but sadly almost no one follows standards nowadays):So yeah, maybe I missed something obvious, but - how do I filter such websites? I've tried checking the hash -
body_md5
is also not present, but funnily enough httpx still gives out the hash (for an empty 0 byte string) in its output when asked:Both word and line count are 1 for a completely empty body, but they can also be 1 for legitimate short responses, so I can't use them to filter out completely empty responses.
Beta Was this translation helpful? Give feedback.
All reactions