@@ -193,10 +193,16 @@ uint8_t *NetworkClient::downloadFileHTTPS(const char *url, int32_t *defaultLen)
193
193
bool sleep = WiFi.getSleep ();
194
194
WiFi.setSleep (false );
195
195
196
- // Create a new HTTP client and connect using HTTPS
196
+ // Create a new HTTP client
197
197
HTTPClient http;
198
198
http.getStream ().setNoDelay (true );
199
199
http.getStream ().setTimeout (1000 );
200
+
201
+ // Set the 'follow redirects' option
202
+ // Default is HTTPC_DISABLE_FOLLOW_REDIRECTS
203
+ http.setFollowRedirects (followRedirects);
204
+
205
+ // Connect with HTTPS
200
206
http.begin (*client, host, 443 , pathToResource, true );
201
207
202
208
// Make GET request
@@ -305,6 +311,12 @@ uint8_t *NetworkClient::downloadFile(const char *url, int32_t *defaultLen)
305
311
HTTPClient http;
306
312
http.getStream ().setNoDelay (true );
307
313
http.getStream ().setTimeout (1 );
314
+
315
+ // Set the 'follow redirects' option
316
+ // Default is HTTPC_DISABLE_FOLLOW_REDIRECTS
317
+ http.setFollowRedirects (followRedirects);
318
+
319
+ // Connect with HTTP
308
320
http.begin (url);
309
321
310
322
int httpCode = http.GET ();
@@ -349,4 +361,21 @@ uint8_t *NetworkClient::downloadFile(const char *url, int32_t *defaultLen)
349
361
WiFi.setSleep (sleep);
350
362
351
363
return buffer;
352
- }
364
+ }
365
+
366
+ /* *
367
+ * @brief Set if Inkplate should follow redirects when making HTTP requests
368
+ *
369
+ * @param followRedirects_t f, the various settings are:
370
+ * -'HTTPC_DISABLE_FOLLOW_REDIRECTS' - no redirection will be followed (default)
371
+ * -'HTTPC_STRICT_FOLLOW_REDIRECTS' - strict RFC2616, only requests using
372
+ * GET or HEAD methods will be redirected
373
+ * -'HTTPC_FORCE_FOLLOW_REDIRECTS' - all redirections will be followed
374
+ *
375
+ * @returns None
376
+ *
377
+ */
378
+ void NetworkClient::setFollowRedirects (followRedirects_t f)
379
+ {
380
+ this ->followRedirects = f;
381
+ }
0 commit comments