Handling large POST data (Mod5282)

Discussion to talk about software related topics only.
Post Reply
res
Posts: 5
Joined: Mon May 09, 2011 5:12 am

Handling large POST data (Mod5282)

Post by res »

Good morning,

I'm sorry in advance that I have missed some trivial piece of information, but I have got stuck on following issue:

I have an application (on Mod5282) with a simple web configuration interface. So far I have got by with HTTP GET methods for passing parameters, but now I need the web interface to upload a larger chunk of data (typically 10kB, let's say up to 50kB) from a form (with TEXTAREA) via the POST method.

I have defined a POST wrapper:

Code: Select all

int PostWrap( int sock, char *url, char *pData, char *rxBuffer )
{
   iprintf("----- Processing Post -----\r\n");
   iprintf("Post URL: %s\r\n", url);
   RedirectResponse( sock, "batch.htm" );
   return 1;
}
... and registered it:

Code: Select all

	SetNewPostHandler( PostWrap );
When I try to upload a few lines it works fine -- the PostWrap() prints the url and the user is redirected to proper page.

But, when I try to submit 5kB of text, the connection times out and there is no output from PostWrap(). The firmware seemingly carries on i.e. the http server responds to other queries and other tasks do their job.

I assume, that I am over-running some buffer anywhere ... if I am right, the question is how can I increase that buffer and even better without altering the system libraries (since I don't want this to interfere with another projects).

Thank you in advance, hope this will be long question-short answer issue :)
Simon
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Handling large POST data (Mod5282)

Post by rnixon »

Not an expert here, but I think you need to use multipart forms. There is an example in the \nburn\examples\web for uploading an application file. If I remember correctly, the issue is you need to allocate a static buffer big enough to hold your largest file size, so its disabled by default to conserve memory.
res
Posts: 5
Joined: Mon May 09, 2011 5:12 am

Re: Handling large POST data (Mod5282)

Post by res »

Yes, this could be the way, nonetheless the multipart forms are useful for uploading a file, not for large data from user inputs :/
User avatar
pbreed
Posts: 1087
Joined: Thu Apr 24, 2008 3:58 pm

Re: Handling large POST data (Mod5282)

Post by pbreed »

Actually the mutipart forms changes the post buffering so it will probably fix you issues as well....


Another way to do this is to edit the variable in nburn\include\constants.h

#define HTTP_RX_BUFFERSIZE (10000)

Make it bigger than recompile the system directory (rebuild all from eclipse)

Paul
Post Reply