File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -231,6 +231,9 @@ class HttpRequest {
231
231
LOGE (" The client has not been defined" );
232
232
return false ;
233
233
}
234
+ if (http_connect_callback){
235
+ http_connect_callback (*this , url, request_header);
236
+ }
234
237
if (!this ->connected ()){
235
238
LOGI (" process connecting to host %s port %d" , url.host (), url.port ());
236
239
int is_connected = connect (url.host (), url.port (), clientTimeout);
@@ -296,6 +299,11 @@ class HttpRequest {
296
299
return reply_header.statusCode ();
297
300
}
298
301
302
+ // / Callback which allows you to add additional paramters dynamically
303
+ void setOnConnectCallback (void (*callback)(HttpRequest &request,Url &url, HttpRequestHeader &request_header)){
304
+ http_connect_callback = callback;
305
+ }
306
+
299
307
protected:
300
308
Client *client_ptr;
301
309
Url url;
@@ -309,6 +317,7 @@ class HttpRequest {
309
317
const char *accept_encoding = nullptr ;
310
318
bool is_ready = false ;
311
319
int32_t clientTimeout = URL_CLIENT_TIMEOUT; // 60000;
320
+ void (*http_connect_callback)(HttpRequest &request,Url &url, HttpRequestHeader &request_header) = nullptr ;
312
321
313
322
// opens a connection to the indicated host
314
323
virtual int connect (const char *ip, uint16_t port, int32_t timeout) {
Original file line number Diff line number Diff line change @@ -211,6 +211,11 @@ class URLStream : public AbstractURLStream {
211
211
request.header ().put (header, value);
212
212
}
213
213
214
+ // / Callback which allows you to add additional paramters dynamically
215
+ void setOnConnectCallback (void (*callback)(HttpRequest &request,Url &url, HttpRequestHeader &request_header)){
216
+ request.setOnConnectCallback (callback);
217
+ }
218
+
214
219
protected:
215
220
HttpRequest request;
216
221
Url url;
You can’t perform that action at this time.
0 commit comments