Giter Club home page Giter Club logo

Comments (2)

verhovsky avatar verhovsky commented on June 8, 2024

If you're talking about Python, this is intentional. If we change your command to

curl 'http://localhost:8888?resolution=1600900'

Then we can see what data it sends by running a simple netcat server with

nc -kl 8888

The curl command sends this data

GET /?resolution=1600*900 HTTP/1.1
Host: localhost:8888
User-Agent: curl/8.4.0
Accept: */*

The generated Python code for that command is

import requests

response = requests.get('http://localhost:8888?resolution=1600*900')

Which is correct because it sends the same query string

GET /?resolution=1600*900 HTTP/1.1
Host: localhost:8888
User-Agent: python-requests/2.31.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive

If you're saying it should generate this code instead

import requests

params = {
    'resolution': '1600*900',
}

response = requests.get('http://localhost:8888', params=params)

then that wouldn't be correct because Requests does percent-encoding in that case and sends this data:

GET /?resolution=1600%2A900 HTTP/1.1

copying as curl from chrome, some characters aren't properly encoded

Is this really true? The browser is sending resolution=1600%2A900 but when you copy as curl it generates a command that sends resolution=1600*900? That would be an issue to fix in "Copy as cURL".

from curlconverter.

Memexurer avatar Memexurer commented on June 8, 2024
def uhhh(url):
    parse_result = urlparse(url)

    dict_result = parse_qs(parse_result.query, keep_blank_values=True)

    for key in dict_result:
        dict_result[key] = dict_result[key][0]

    pp = pprint.PrettyPrinter(indent=4,  sort_dicts=False)
    pp.pprint(dict_result)

anyways, here's a python code for generating that query params manually
might help if someone finds this issue...

from curlconverter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.