Bug in send_http_response_body


the current implementaion of “send_http_response_body” leaves the file_name variable unset if the length of the file is shorter than file_len > DATA_BUF_SIZE - 1. The block from line 358 to 365 has to be moved between 351 and 352. Additionally to this thread I added an isue at GIT.

Hi, Knut.

What exactly are you talking about?
As shown below, a smaller size than the buffer size was also transferred without any problems (WIZnet icon).

I think I am misunderstanding your intentions, so please explain the exact situation.


Best regard,

Hi Kei,

this is the code from httpServer.c I downloaded: I just checked [url]https://github.com/Wiznet/WIZ550web/blob/master/WIZ550web_Firmware/WIZ550web_HW_Rev1.1/WIZ550web_App/src/Internet/httpServer/httpServer.c[/url] and even there it is the same. What I mean is the “///////…” part. This part copies the uri-name to the file name but only if the file is bigger than the transfer buffer. How do I get the file name for the first reading?
I got the problem while the SW reads the URL from the SD-card. I do not have a HW-flash, therefore I did not check this path.

[code]static void send_http_response_body(uint8_t s, uint8_t * uri_name, uint8_t * buf, uint32_t start_addr, uint32_t file_len)

// Send the HTTP Response 'body'; requested file
if(!HTTPSock_Status[get_seqnum].file_len) // ### Send HTTP response body: First part ###
	if (file_len > DATA_BUF_SIZE - 1)
		HTTPSock_Status[get_seqnum].file_start = start_addr;
		HTTPSock_Status[get_seqnum].file_len = file_len;
		send_len = DATA_BUF_SIZE - 1;

// ## 20141219 Eric added, for ‘File object structure’ (fs) allocation reduced (8 → 1)
memset(HTTPSock_Status[get_seqnum].file_name, 0x00, MAX_CONTENT_NAME_LEN);
strcpy((char *)HTTPSock_Status[get_seqnum].file_name, (char *)uri_name);
printf(“> HTTPSocket[%d] : HTTP Response body - file name [ %s ]\r\n”, s, HTTPSock_Status[get_seqnum].file_name);
// Send process end
send_len = file_len;

printf(“> HTTPSocket[%d] : HTTP Response end - file len [ %ld ]byte\r\n”, s, send_len);


1 Like

First, there is a reason to store uri in a separate structure for data larger than the buffer size.

When a request comes from a client in the idle state, it responds immediately.
That is, for a response that does not exceed the buffer size, the response state is completed by that processing.

On the other hand, for responses that exceed the buffer size, you must send them multiple times.
For this reason, the module is to save the uri that was being sent to a special structure to remember.
(That’s why wrote the code ///// )

Best regard,