Request size limit

16 views
Skip to first unread message

co...@azuqua.com

unread,
May 26, 2016, 3:27:31 PM5/26/16
to onion-dev
Hi,

I see that by default the max POST size is 1M, however I'm experiencing an issue where anything greater than 1.5K won't get to my server. By that I mean from the logs it looks like the server never gets hit with a request. 

I used onion_set_max_post_size with size_t param of 1048576 with no change, I then set it to much lower 512 and saw:
[D1DD9700] [2016-05-26 12:12:42] [ERROR request_parser.c:1067] Trying to set more data at server than allowed 512
which is what I would expect - so it's clear that before there was not a limit set by onion_set_max_post_size which is disallowing requests of 1.5K to get through.

The data that I am handling is JSON, here is some potentially relevant code snippets:


// handler
int handle_request(void * _, onion_request * req, onion_response * res){
  printf
("handle request...\n");

...

// server initialization
static void initialize_server(){
  o
= onion_new(O_THREADED);
  onion_set_timeout
(o, 5000);
  onion_set_hostname
(o, "0.0.0.0");
  onion_set_port
(o, 4040);
  onion_set_max_post_size
(o, 1048576);
  onion_url
* url = onion_root_url(o);
  onion_url_add
(url, "^(.*)$", (void*)handle_request);
  INFO
("server listening on port %s", 4040);
  onion_listen
(o);
  cleanup
(o, url);
}


Colin James

unread,
May 26, 2016, 9:55:19 PM5/26/16
to onion-dev, co...@azuqua.com
Looking more into it, it seems like the issue is related to how I am getting POST data:

  const onion_block * onion_request_data = onion_request_get_data(req);

I am doing this because I would like to use my own internal JSON library, and with onion_block I am able to serialize it to a JSON string and then parse with the other library.

Is there a better way to do this?
Best regards,
Colin

co...@azuqua.com

unread,
May 26, 2016, 11:12:10 PM5/26/16
to onion-dev, co...@azuqua.com
Unfortunately, although using onion_request_get_data is related to why the problem is occurring it seems more internal internal than that. 
With a bare bones handler:

onion_connection_status post_data(void *_, onion_request *req, onion_response *res){
  onion_response_printf
(res, "response...");
 
return OCS_PROCESSED;
}

onion fails to make a response when raw body data exceeds 1.5K. Onion handles form-data POSTs exceeding 1.5K.

Colin James

unread,
May 27, 2016, 12:31:29 AM5/27/16
to onion-dev, co...@azuqua.com
The solution I am going with is to use onion_request_get_post. The server will be hit with multipart/form-data. To handle JSON it will be stringified and the string will be parsed. Will keep this up in case it helps others.

David Moreno Montero

unread,
May 27, 2016, 4:35:02 AM5/27/16
to Colin James, onion-dev
Hi,

I will add an issue ticket and try fix it, but just to be sure, in the original problem you are sending a JSON POST, with the idea of retrieving it fully and parse it yourself. 

Is it right?

If its this, just now, as you discovered there is only support for multipart and urlencoded POSTs, you can do what you need using PUT and onion_request_get_data. 

Regards,
David

--
You received this message because you are subscribed to the Google Groups "onion-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to onion-dev+...@coralbits.com.
To post to this group, send email to onio...@coralbits.com.
Visit this group at https://groups.google.com/a/coralbits.com/group/onion-dev/.
For more options, visit https://groups.google.com/a/coralbits.com/d/optout.



--

Colin Gabrielson

unread,
May 27, 2016, 1:30:24 PM5/27/16
to David Moreno Montero, onion-dev

Hey David,

Thanks for following up on this. Yes that is the case I am sending JSON POST data. When testing this with postman i was unable to hit the server with payloads >1.5K data. This includes, but isn't limited to JSON and plaintext.

I appreciate your work,
Colin

Reply all
Reply to author
Forward
0 new messages