@@ -124,12 +124,6 @@ static size_t write_header(char* ptr, size_t size, size_t nmemb, void* userdata)
124
124
return size * nmemb;
125
125
}
126
126
127
- static std::string const & get_user_agent_header ()
128
- {
129
- static std::string user_agent = std::string (" User-Agent: AWS_Lambda_Cpp/" ) + get_version ();
130
- return user_agent;
131
- }
132
-
133
127
static size_t read_data (char * buffer, size_t size, size_t nitems, void * userdata)
134
128
{
135
129
auto const limit = size * nitems;
@@ -163,10 +157,12 @@ static int rt_curl_debug_callback(CURL* handle, curl_infotype type, char* data,
163
157
}
164
158
#endif
165
159
166
- runtime::runtime (std::string const & endpoint)
167
- : m_endpoints{{endpoint + " /2018-06-01/runtime/init/error" ,
168
- endpoint + " /2018-06-01/runtime/invocation/next" ,
169
- endpoint + " /2018-06-01/runtime/invocation/" }},
160
+ runtime::runtime (std::string const & endpoint) : runtime(endpoint, " AWS_Lambda_Cpp/" + std::string(get_version())) {}
161
+
162
+ runtime::runtime (std::string const & endpoint, std::string const & user_agent)
163
+ : m_user_agent_header(" User-Agent: " + user_agent), m_endpoints{{endpoint + " /2018-06-01/runtime/init/error" ,
164
+ endpoint + " /2018-06-01/runtime/invocation/next" ,
165
+ endpoint + " /2018-06-01/runtime/invocation/" }},
170
166
m_curl_handle (curl_easy_init())
171
167
{
172
168
if (!m_curl_handle) {
@@ -234,7 +230,7 @@ runtime::next_outcome runtime::get_next()
234
230
curl_easy_setopt (m_curl_handle, CURLOPT_HEADERDATA, &resp);
235
231
236
232
curl_slist* headers = nullptr ;
237
- headers = curl_slist_append (headers, get_user_agent_header () .c_str ());
233
+ headers = curl_slist_append (headers, m_user_agent_header .c_str ());
238
234
curl_easy_setopt (m_curl_handle, CURLOPT_HTTPHEADER, headers);
239
235
240
236
logging::log_debug (LOG_TAG, " Making request to %s" , m_endpoints[Endpoints::NEXT].c_str ());
@@ -339,7 +335,7 @@ runtime::post_outcome runtime::do_post(
339
335
340
336
headers = curl_slist_append (headers, " Expect:" );
341
337
headers = curl_slist_append (headers, " transfer-encoding:" );
342
- headers = curl_slist_append (headers, get_user_agent_header () .c_str ());
338
+ headers = curl_slist_append (headers, m_user_agent_header .c_str ());
343
339
auto const & payload = handler_response.get_payload ();
344
340
logging::log_debug (
345
341
LOG_TAG, " calculating content length... %s" , (" content-length: " + std::to_string (payload.length ())).c_str ());
0 commit comments