postmanlabs / postman-code-generators

Common repository for all code generators shipped with Postman
Apache License 2.0
992 stars 350 forks source link

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

Open yizhao1998 opened 4 months ago

yizhao1998 commented 4 months ago

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