postmanlabs / postmanlabs/postman-code-generators
python.http-client generates code snippet not workable for http protocol
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 381
- PR merge metrics
- No merged PRs in 30d
Description
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:
- Open postman, put
http://localhost:3000into the url input box. - Generate code with python - http.client.
- Put snippet into
test.pyand runpython3 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:
Additional context
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the python.http-client generator and reproduce the issue with an http:// URL such as http://localhost:3000. Check the generated connection type against the URL protocol, then run the generated script to confirm it completes without the reported SSL error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100