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

[HTTP server] in send_data, the client state is possibly incorrect #11

Open
phalox opened this issue Jan 25, 2016 · 3 comments
Open

[HTTP server] in send_data, the client state is possibly incorrect #11

phalox opened this issue Jan 25, 2016 · 3 comments
Assignees

Comments

@phalox
Copy link
Contributor

phalox commented Jan 25, 2016

ref https://github.com/tass-belgium/picotcp-modules/blob/master/libhttp/pico_http_server.c#L867

void send_data(struct http_client client)
{
uint16_t length;
while (client->buffer_sent < client->buffer_size &&
(length = (uint16_t)pico_socket_write(client->sck, (uint8_t *)client->buffer + client->buffer_sent,
client->buffer_size - client->buffer_sent)) > 0 )
{
client->buffer_sent = (uint16_t)(client->buffer_sent + length);
server.wakeup(EV_HTTP_PROGRESS, client->connectionID);
}
if (client->buffer_sent == client->buffer_size && client->buffer_size)
{
/
send chunk trail /
if (pico_socket_write(client->sck, "\r\n", 2) > 0)
{
/
free the buffer */
if (client->state == HTTP_SENDING_DATA)
{
PICO_FREE(client->buffer);
}

        client->buffer = NULL;

        //client->state = HTTP_WAIT_DATA;             << if you do that, for large static_data (HTTP_STATIC_RESOURCE), the memory will be allocated & copied on next line if server submit data....
        client->state = (client->state == HTTP_SENDING_DATA) ? HTTP_WAIT_DATA : HTTP_WAIT_STATIC_DATA;                                     << the code should have been like that
        server.wakeup(EV_HTTP_SENT, client->connectionID);
    }
}

}

@phalox
Copy link
Contributor Author

phalox commented Jan 25, 2016

@robbinvandamme Can you have a look at this?

@robbinvandamme
Copy link
Contributor

Haven't been working on the server, so I won't be able to take a "quick look" at this.

@phalox
Copy link
Contributor Author

phalox commented Jan 25, 2016

@WimLeflere I believe you're the right person to talk to. Could you have a look at this suggestion to see if it makes sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants