Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python.http-client generates code snippet not workable for http protocol #746

Open
yizhao1998 opened this issue May 25, 2024 · 0 comments
Open

Comments

@yizhao1998
Copy link
Contributor

Describe the bug
For url using http protocol, python.http-client still generates conn = http.client.HTTPSConnection. Python would throw SSL error when running the script.

To Reproduce
Steps to reproduce the behavior:

  1. Open postman, put http://localhost:3000 into the url input box.
  2. Generate code with python - http.client.
  3. Put snippet into test.py and run python3 test,py, you will see the SSL error.

Expected code snippet and corresponding request
Change http.client.HTTPSConnection to http.client.HTTPConnection would resolve the issue. Complete code:

import http.client

conn = http.client.HTTPConnection("localhost", 3000)
payload = ''
headers = {}
conn.request("GET", "/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Screenshots
Current postman screenshot:
Screenshot 2024-05-25 at 11 30 30 AM

Additional context
N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant