From 21307a09b4016bf668947ac359a548694dc1aac3 Mon Sep 17 00:00:00 2001 From: John Lin Date: Thu, 28 Aug 2025 19:28:12 -0700 Subject: [PATCH] fix: Use standard \r\n for the http custom header to avoid problem get/post to http servers --- examples/http/get_with_custom_header.py | 6 +++--- examples/http/post_with_custom_header.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/http/get_with_custom_header.py b/examples/http/get_with_custom_header.py index 3b1dd3f..628e286 100644 --- a/examples/http/get_with_custom_header.py +++ b/examples/http/get_with_custom_header.py @@ -43,14 +43,14 @@ # Custom header -HEADER = "\n".join( +HEADER = "\r\n".join( [ f"GET {query} HTTP/1.1", f"Host: {host}", "Custom-Header-Name: Custom-Data", "Content-Type: application/json", - "Content-Length: 0\n", - "\n\n", + "Content-Length: 0", + "\r\n", ] ) diff --git a/examples/http/post_with_custom_header.py b/examples/http/post_with_custom_header.py index b0aae0d..55994b6 100644 --- a/examples/http/post_with_custom_header.py +++ b/examples/http/post_with_custom_header.py @@ -46,14 +46,14 @@ payload = json.dumps(DATA_TO_POST) # Custom header -HEADER = "\n".join( +HEADER = "\r\n".join( [ f"POST /{query} HTTP/1.1", f"Host: {host}", "Custom-Header-Name: Custom-Data", "Content-Type: application/json", - f"Content-Length: {len(payload)+1}", - "\n\n", + f"Content-Length: {len(payload) + 1}", + "\r\n", ] )