Body length of HTTP POST
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: Body length of HTTP POST
by Eugeny ·
I did not get the problem. You first get data until CRLFCRLF, then you parse headers and get content length, and then get ‘content-length’ bytes of data. Whatever content-length value is, you keep calling receive function until get all the data or timeout occurs.
RE: RE: Body length of HTTP POST
by Vien Huy Nguyen ·
Hi Eugeny,
On the first recv() call in the http_run() routine, it read the first segment which includes the header and 1kB data body. I want to copy this 1kB data to some other buffers.
In other words, how do I know the length of the part of body that in the initial segment with the header? (the first 1kB that I mentioned. I know it is 1kB because I monitor it using Wireshark, not by the firmware. I want to get this number in the firmware)
The segments are as follow:
1st segment: header + 1kB of data
2nd segment: 1kB of data
… until everything is sent.
RE: Body length of HTTP POST
by Eugeny ·
Do you need to? What you know for sure you will NOT (should) get more data than the data size in content-length.
And you know total this data size from content-length, and you know size of the header which ends with CRLFCRLF, and you know size of data you received from recv(), thus you can calculate how much exact data is in the first packet, and how much data will follow.
RE: Body length of HTTP POST
by Vien Huy Nguyen ·
Yes, because I want to use memcpy() the copy the data somewhere else, I have the pointer pointing to the data using strstr((char*)uri, “\r\n\r\n”), I need to know the size of this (1kB) to call memcpy(). The buffer holds the copy of the data is used to write to a flash IC to save the data.
How do you process a piece of data not knowing its size?
That is exactly what I am trying to do. The problem is I cannot get the header size.
Do you use the provided httpServer by WIZnet or do you write or own code? As I tried to explain in the question, the library use strtok() to break down the request into three parts and save them in a st_http_request struct. Then the URI element of this struct is used to continue to process the http request. This loses track of the header length.
RE: Body length of HTTP POST
by Eugeny ·
No I do not use library. And you must be able to find pointer to the start of data using
strstryou mentioned, therefore you know the size of header. Then there must be a way to know how much data exactly you have got usingrecvfunction, and to know data size you subtract header size from the size received byrecv.