kylebebak / Requester

Powerful, modern HTTP/REST client built on top of the Requests library
https://kylebebak.github.io/Requester/
MIT License
307 stars 10 forks source link

[import from curl] Conversion Error: too many values to unpack (expected 2) #3

Closed Jambon1510 closed 7 years ago

Jambon1510 commented 7 years ago

Behavior when trying to convert from curl to python and if the curl command is too long, we have the below error: Conversion Error: too many values to unpack (expected 2)

example: curl 'https://wwws.myurl.com/secured/js/dispatch' -H 'Cookie: myurlPViewSelection=87399; __utmt=1; JSESSIONID=968EBCA9EAD5791260578867A00E3E28; myurlSession=A34613179A; myurlSessionTimeout=15; __utma=80772746.544579460.1499001932.1500851877.1500904258.12; __utmb=80772746.17.10.1500904258; __utmc=80772746; __utmz=80772746.1499001932.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)' -H 'Origin: https://wwws.myurl.com' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.8,fr;q=0.6' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36' -H 'Content-Type: text/x-gwt-rpc; charset=UTF-8' -H 'Accept: */*' -H 'X-GWT-Module-Base: https://wwws.myurl.com/secured/js/' -H 'X-GWT-Permutation: DB8126A36E6BF1903AACA5D5D293D391' -H 'Referer: https://wwws.myurl.com/secured/overview.page' -H 'Connection: keep-alive' --data-binary '7|0|7|https://wwws.myurl.com/secured/js/|A45A6D59315E9C9D16DD02A633694270|net.customware.gwt.dispatch.client.standard.StandardDispatchService|execute|net.customware.gwt.dispatch.shared.Action|com.myurl.gwt.rpc.client.user.GetDealAction/3545658020|A34613179A|1|2|3|4|1|5|6|7|' --compressed

Expected Behavior when trying to convert from curl to python and if the curl command is long, it should convert same as shorter curl command

kylebebak commented 7 years ago

@Jambon1510 Hey, thanks for the heads up!

This was due to a bug in how headers were being parsed. It's been fixed.

I'll release version 2.11.1 with this fix in a day or two.

kylebebak commented 7 years ago

@Jambon1510 So this bug is fixed in 2.12.0, you can now import that your cURL request. Thanks again for the heads up, I'm going to close this.

Jambon1510 commented 7 years ago

Another error now, should I create another issue?

Parse Error: there may be unbalanced brackets in tests and the following code is generated


"""
RUN TESTS: `python -m unittest requester_tests`
MORE INFO: https://docs.python.org/3/library/unittest.html#command-line-interface
2017-08-24 21:55:46
"""
import unittest

import requests

# --- ENV --- #

# --- ENV --- #

class TestResponses(unittest.TestCase):

if __name__ == '__main__':
    unittest.main()
kylebebak commented 7 years ago

@Jambon1510

Hey there. That error message means your requests can't be parsed because there's a syntax error in the requests.

It's possible that the requests are valid and there's a bug in the parser, but I can't know unless you include the requests that you tried to export to your test script. Please reply with the requests that you were trying to export.

Jambon1510 commented 7 years ago

Hi Kyle, Sorry, I am using the exact same request as in my first comment (I did a copy from the webpage and paste in Sublime, not sure if it has introduced some weird characters)

kylebebak commented 7 years ago

Hey there, now I understand what's happening. You have a request and you want to export it to a runnable test script.

The problem is that you haven't made any assertions about your request! You need to make an assertion about your request, and then you can export the request/assertion pair to your runnable test script. See how here in the documentation.

Let me know how this goes for you.