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

can not get post data by example "post" #287

Open
wjefen opened this issue May 10, 2021 · 4 comments
Open

can not get post data by example "post" #287

wjefen opened this issue May 10, 2021 · 4 comments

Comments

@wjefen
Copy link

wjefen commented May 10, 2021

i send date by curl,but can't get any data
i trace it, the dict's key was data,not content-type,is it bug?

debug info:
onion_dict_find_node (d=0x615df0, current=0x62a220, key=0x400e58 "application", parent=0x0) at */onion-master/src/onion/dict.c:231
231 if (!current) {
(gdb) n
234 int cmp = d->cmp(key, current->data.key);
(gdb) p key
$79 = 0x400e58 "application" #### I modify the example (text->application)
(gdb) p current->data.key #### it is debug data saved to dict
$80 = 0x615da0 "{"input_1": "111sunshine"}"

the cmd i used:
curl --trace test.txt --data '{"input_1": "111sunshine"}' http://127.0.0.1:8080/data

@davidmoreno
Copy link
Owner

davidmoreno commented May 10, 2021 via email

@wjefen
Copy link
Author

wjefen commented May 11, 2021

the req->data is null
(gdb) p *req
$2 = {connection = {listen_point = 0x615280, user_data = 0x0, fd = 7, cli_addr = {ss_family = 2, __ss_padding = "\231\026\177\000\000\001", '\000' <repeats 111 times>, __ss_align = 0}, cli_len = 16,
cli_info = 0x0}, flags = 273, fullpath = 0x615310 "/data", path = 0x615315 "", headers = 0x62a1a0, GET = 0x615330, POST = 0x615df0, FILES = 0x0, session = 0x0, data = 0x0, cookies = 0x0, session_id = 0x0,
parser = 0x7ffff79bf73f <parse_POST_urlencode>, parser_data = 0x628180, websocket = 0x0, free_list = 0x615dd0}

if I input the format as --data "key1=xx&key2=xxx",onion_request_get_post(x,key1)can get the data,

in the func "parse_POST_urlencode",token->extra can get the raw data,but "token->extra = NULL" before return " will dissipates it
i donot know how to get raw data

Can you try using onion_request_get_data.

@wjefen
Copy link
Author

wjefen commented May 13, 2021

onion_request_get_data will get req->data

the req->data is null
(gdb) p *req
$2 = {connection = {listen_point = 0x615280, user_data = 0x0, fd = 7, cli_addr = {ss_family = 2, __ss_padding = "\231\026\177\000\000\001", '\000' <repeats 111 times>, __ss_align = 0}, cli_len = 16,
cli_info = 0x0}, flags = 273, fullpath = 0x615310 "/data", path = 0x615315 "", headers = 0x62a1a0, GET = 0x615330, POST = 0x615df0, FILES = 0x0, session = 0x0, data = 0x0, cookies = 0x0, session_id = 0x0,
parser = 0x7ffff79bf73f <parse_POST_urlencode>, parser_data = 0x628180, websocket = 0x0, free_list = 0x615dd0}

if I input the format as --data "key1=xx&key2=xxx",onion_request_get_post(x,key1)can get the data,

in the func "parse_POST_urlencode",token->extra can get the raw data,but "token->extra = NULL" before return " will dissipates it
i donot know how to get raw data

Can you try using onion_request_get_data.

i have debuged it ,onion_request_get_data will get req->data

@wjefen
Copy link
Author

wjefen commented May 13, 2021

oh,I can get raw data by req->POST->root->data->key,
the data is Unique key of the dictionary,
is it not support api to get this?
I has seen the code of "examples\jsonrpc\jsonrpc.c",the callback fun will call onion_request_get_data,the func will return req->data
I debuged it ,the req->data was NULL, only Through by POST(dict),why?

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

2 participants