1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

minimal-http-server-post: redirect does its own header write

https://github.com/warmcat/libwebsockets/issues/1218
This commit is contained in:
Andy Green 2018-04-18 18:31:57 +08:00
parent 8829c2f365
commit b9b100bdfd
3 changed files with 5 additions and 26 deletions

View file

@ -4520,7 +4520,7 @@ lws_return_http_status(struct lws *wsi, unsigned int code,
const char *html_body);
/**
* lws_http_redirect() - write http redirect into buffer
* lws_http_redirect() - write http redirect out on wsi
*
* \param wsi: websocket connection
* \param code: HTTP response code (eg, 301)
@ -4528,6 +4528,8 @@ lws_return_http_status(struct lws *wsi, unsigned int code,
* \param len: length of loc
* \param p: pointer current position in buffer (updated as we write)
* \param end: pointer to end of buffer
*
* Returns amount written, or < 0 indicating fatal write failure.
*/
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_http_redirect(struct lws *wsi, int code, const unsigned char *loc, int len,

View file

@ -162,18 +162,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
if (lws_http_redirect(wsi, HTTP_STATUS_MOVED_PERMANENTLY,
(unsigned char *)"after-form1.html",
16, &p, end))
return -1;
/* we could add more headers here */
if (lws_finalize_http_header(wsi, &p, end))
return -1;
n = lws_write(wsi, start, lws_ptr_diff(p, start),
LWS_WRITE_HTTP_HEADERS |
LWS_WRITE_H2_STREAM_END);
if (n < 0)
16, &p, end) < 0)
return -1;
break;

View file

@ -106,20 +106,8 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
if (lws_http_redirect(wsi, HTTP_STATUS_MOVED_PERMANENTLY,
(unsigned char *)"after-form1.html",
16, &p, end))
16, &p, end) < 0)
return -1;
/* we could add more headers here */
if (lws_finalize_http_header(wsi, &p, end))
return -1;
n = lws_write(wsi, start, lws_ptr_diff(p, start),
LWS_WRITE_HTTP_HEADERS |
LWS_WRITE_H2_STREAM_END);
if (n < 0)
return -1;
break;
case LWS_CALLBACK_HTTP_DROP_PROTOCOL: