Skip to content

Commit

Permalink
[support presigned URL] support http request without HTTP_USER_AGENT_…
Browse files Browse the repository at this point in the history
…FIELD (#164)

* Added flag HTTP_REQUEST_NO_USER_AGENT_FLAG to skip adding HTTP_USER_AGENT_FIELD needed for presigned URL

* Uncrustify: triggered by comment

* fixed doxygen comment

* Update size_table.md

---------

Co-authored-by: Giuseppe Penone <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: Soren Ptak <[email protected]>
  • Loading branch information
4 people authored Oct 25, 2023
1 parent 76e516c commit 15213f4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/doxygen/include/size_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</tr>
<tr>
<td>core_http_client.c</td>
<td><center>3.1K</center></td>
<td><center>3.2K</center></td>
<td><center>2.5K</center></td>
</tr>
<tr>
Expand All @@ -29,7 +29,7 @@
</tr>
<tr>
<td><b>Total estimates</b></td>
<td><b><center>23.9K</center></b></td>
<td><b><center>24.0K</center></b></td>
<td><b><center>20.7K</center></b></td>
</tr>
</table>
15 changes: 9 additions & 6 deletions source/core_http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1632,12 +1632,15 @@ HTTPStatus_t HTTPClient_InitializeRequestHeaders( HTTPRequestHeaders_t * pReques

if( returnStatus == HTTPSuccess )
{
/* Write "User-Agent: <Value>". */
returnStatus = addHeader( pRequestHeaders,
HTTP_USER_AGENT_FIELD,
HTTP_USER_AGENT_FIELD_LEN,
HTTP_USER_AGENT_VALUE,
HTTP_USER_AGENT_VALUE_LEN );
if( ( HTTP_REQUEST_NO_USER_AGENT_FLAG & pRequestInfo->reqFlags ) == 0U )
{
/* Write "User-Agent: <Value>". */
returnStatus = addHeader( pRequestHeaders,
HTTP_USER_AGENT_FIELD,
HTTP_USER_AGENT_FIELD_LEN,
HTTP_USER_AGENT_VALUE,
HTTP_USER_AGENT_VALUE_LEN );
}
}

if( returnStatus == HTTPSuccess )
Expand Down
13 changes: 12 additions & 1 deletion source/include/core_http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,18 @@
*
* This flag is valid only for #HTTPRequestInfo_t reqFlags parameter.
*/
#define HTTP_REQUEST_KEEP_ALIVE_FLAG 0x1U
#define HTTP_REQUEST_KEEP_ALIVE_FLAG 0x1U

/**
* @ingroup http_request_flags
* @brief Set this flag to skip the User-Agent in the request headers.
*
* Setting this will cause the "User-Agent: <Value>" to be omitted in the
* request headers.
*
* This flag is valid only for #HTTPRequestInfo_t reqFlags parameter.
*/
#define HTTP_REQUEST_NO_USER_AGENT_FLAG 0x2U

/**
* @defgroup http_response_flags HTTPResponse_t Flags
Expand Down

0 comments on commit 15213f4

Please sign in to comment.