postmanlabs / postmanlabs/postman-code-generators

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

Open
#746 0 comments 0 reactions 0 assignees View on GitHub

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:

  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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.