Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected conversion during a requests.post() operation #901

Open
rvisc opened this issue Feb 2, 2022 · 0 comments
Open

Unexpected conversion during a requests.post() operation #901

rvisc opened this issue Feb 2, 2022 · 0 comments

Comments

@rvisc
Copy link

rvisc commented Feb 2, 2022

I noticed an unusual behavior of HUG when sending data to the server through a requests.post() in AWS environment:

  • I create the body of the message by defining a dict that contains three lists of strings;

my_params = {'ips': ['3.4.5.6'], 'nums_a': ['7', '8', '9', '10'], 'nums_b': ['11', '12', '13']}

  • the structure is then sent to the server which performs some operations on the three lists of data;

requests.post("http://" + server_ip + ":8001/start_service", my_params).json()`

  • if the lists in the body contain more than one value, everything works smoothly;
@hug.post('/start_nmap_service')
def start_service(body):
    print(body["nums_a"])

--> ['7', '8', '9', '10']
  • if a list contains only one string value, the method receiving the request gets a string, not a list containing a string.

@hug.post('/start_nmap_service')
def start_service(body):
print(body["ips"])

--> '3.4.5.6'

This behaviour does not occur if the same code is executed locally using docker-compose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant