curlconverter / curlconverter

Transpile curl commands into Python, JavaScript and 27 other languages
https://curlconverter.com
MIT License
7.21k stars 876 forks source link

header fields are ignored #47

Closed ErKatz closed 7 years ago

ErKatz commented 7 years ago

Hi. Consider the following Curl Command:

curl -X GET --header 'Accept: application/json' --header 'user-token: 75d7ce4350c7d6239347bf23d3a3e668' 'http://localhost:8080/api/retail/books/list'

It gets converted to:

import requests

requests.get('http://localhost:8080/api/retail/books/list')

the "user-token" is ignored. Instead it should be converted to:

import requests

requests.get('http://localhost:8080/api/retail/books/list',headers={'user-token': '75d7ce4350c7d6239347bf23d3a3e668')
einstein95 commented 7 years ago

Replacing --header with -H works

import requests

headers = {
    'Accept': 'application/json',
    'user-token': '75d7ce4350c7d6239347bf23d3a3e668',
}

requests.get('http://localhost:8080/api/retail/books/list', headers=headers)