[core,gateway] add http_request_append_header

This commit is contained in:
akallabeth
2025-10-27 12:19:10 +01:00
parent c8698a1b9c
commit e9890c3960
2 changed files with 20 additions and 1 deletions

View File

@@ -1486,7 +1486,7 @@ HttpResponse* http_response_recv(rdpTls* tls, BOOL readContentLength)
WINPR_ASSERT(response->BodyLength == 0);
bodyLength = response->BodyLength; /* expected body length */
if (readContentLength)
if (readContentLength && (response->BodyLength > 0))
{
const char* cur = response->ContentType;
@@ -1737,3 +1737,18 @@ void http_response_log_error_status_(wLog* log, DWORD level, const HttpResponse*
freerdp_http_status_string_format(status, buffer, ARRAYSIZE(buffer)));
http_response_print(log, level, response, file, line, fkt);
}
WINPR_ATTR_FORMAT_ARG(3, 4)
BOOL http_request_append_header(wStream* stream, const char* param,
WINPR_FORMAT_ARG const char* value, ...)
{
va_list ap;
va_start(ap, value);
char* str = NULL;
size_t slen = 0;
winpr_vasprintf(&str, &slen, value, ap);
va_end(ap);
const BOOL rc = http_encode_body_line(stream, param, str);
free(str);
return rc;
}

View File

@@ -104,6 +104,10 @@ FREERDP_LOCAL BOOL http_request_set_transfer_encoding(HttpRequest* request,
FREERDP_LOCAL wStream* http_request_write(HttpContext* context, HttpRequest* request);
WINPR_ATTR_FORMAT_ARG(3, 4)
FREERDP_LOCAL BOOL http_request_append_header(wStream* stream, const char* param,
WINPR_FORMAT_ARG const char* value, ...);
/* HTTP response */
typedef struct s_http_response HttpResponse;