Skip to content
Snippets Groups Projects
Commit 658c7529 authored by Andy Green's avatar Andy Green
Browse files

lws_add_http_common_headers: provide WSI_TOKEN_HTTP_CONTENT_TYPE helper

parent 3f683351
Branches
Tags
No related merge requests found
......@@ -4307,6 +4307,8 @@ LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_finalize_write_http_header(struct lws *wsi, unsigned char *start,
unsigned char **p, unsigned char *end);
#define LWS_ILLEGAL_HTTP_CONTENT_LEN ((lws_filepos_t)-1ll)
/**
* lws_add_http_common_headers() - Helper preparing common http headers
*
......@@ -4327,6 +4329,9 @@ lws_finalize_write_http_header(struct lws *wsi, unsigned char *start,
* commonly needed. If it doesn't fit your case, or you want to add additional
* headers just call the public apis directly yourself for what you want.
*
* You can miss out the content length header by providing the constant
* LWS_ILLEGAL_HTTP_CONTENT_LEN for the content_len.
*
* It does not call lws_finalize_http_header(), to allow you to add further
* headers after calling this. You will need to call that yourself at the end.
*/
......
......
......@@ -143,11 +143,14 @@ lws_add_http_common_headers(struct lws *wsi, unsigned int code,
{
if (lws_add_http_header_status(wsi, code, p, end))
return 1;
if (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_CONTENT_TYPE,
(unsigned char *)content_type,
(int)strlen(content_type), p, end))
return 1;
if (lws_add_http_header_content_length(wsi, content_len, p, end))
if (content_len != LWS_ILLEGAL_HTTP_CONTENT_LEN &&
lws_add_http_header_content_length(wsi, content_len, p, end))
return 1;
return 0;
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment