Skip to content

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

@yizhao1998

Description

@yizhao1998

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions