File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -234,15 +234,15 @@ class AsyncHttp {
234234 + http->host .length ()
235235 + http->path .length ()
236236 + 32 ;
237- std::unique_ptr< char []> headers ( new (std::nothrow) char [ headers_len + 1 ] );
237+ char * headers = ( char *) malloc ( headers_len + 1 );
238238
239239 if (!headers) {
240240 ASYNC_HTTP_DEBUG (" err | alloc %u fail\n " , headers_len + 1 );
241241 client->close (true );
242242 return ;
243243 }
244244
245- int res = snprintf_P (headers. get () , headers_len + 1 ,
245+ int res = snprintf_P (headers, headers_len + 1 ,
246246 HTTP_REQUEST_TEMPLATE ,
247247 http->method .c_str (),
248248 http->path .c_str (),
@@ -251,11 +251,14 @@ class AsyncHttp {
251251 );
252252 if (res >= (headers_len + 1 )) {
253253 ASYNC_HTTP_DEBUG (" err | res>=len :: %u>=%u\n " , res, headers_len + 1 );
254+ free (headers);
254255 client->close (true );
255256 return ;
256257 }
257258
258- client->write (headers.get ());
259+ client->write (headers);
260+ // TODO: streaming data source instead of using a simple String
261+ // TODO: move to onPoll, ->add(data) and ->send() until it can't (returns 0), then repeat
259262 client->write (http->data .c_str ());
260263
261264 }
You can’t perform that action at this time.
0 commit comments