@@ -71,10 +71,10 @@ TEST_CASE("HTTP GET & POST requests", "[HTTPClient]")
71
71
http.end ();
72
72
}
73
73
{
74
- // 301 redirect with follow enabled
74
+ // GET 301 redirect with strict RFC follow enabled
75
75
WiFiClient client;
76
76
HTTPClient http;
77
- http.setFollowRedirects (true );
77
+ http.setFollowRedirects (HTTPC_STRICT_FOLLOW_REDIRECTS );
78
78
String uri = String (" /redirect301?host=" )+getenv (" SERVER_IP" );
79
79
http.begin (client, getenv (" SERVER_IP" ), 8088 , uri.c_str ());
80
80
auto httpCode = http.GET ();
@@ -83,7 +83,7 @@ TEST_CASE("HTTP GET & POST requests", "[HTTPClient]")
83
83
REQUIRE (payload == " redirect success" );
84
84
}
85
85
{
86
- // 301 redirect with follow disabled
86
+ // GET 301 redirect with follow disabled
87
87
WiFiClient client;
88
88
HTTPClient http;
89
89
String uri = String (" /redirect301?host=" )+getenv (" SERVER_IP" );
@@ -92,10 +92,10 @@ TEST_CASE("HTTP GET & POST requests", "[HTTPClient]")
92
92
REQUIRE (httpCode == 301 );
93
93
}
94
94
{
95
- // 302 redirect with follow enabled
95
+ // GET 302 redirect with strict RFC follow enabled
96
96
WiFiClient client;
97
97
HTTPClient http;
98
- http.setFollowRedirects (true );
98
+ http.setFollowRedirects (HTTPC_STRICT_FOLLOW_REDIRECTS );
99
99
String uri = String (" /redirect302?host=" )+getenv (" SERVER_IP" );
100
100
http.begin (client, getenv (" SERVER_IP" ), 8088 , uri.c_str ());
101
101
auto httpCode = http.GET ();
@@ -104,7 +104,7 @@ TEST_CASE("HTTP GET & POST requests", "[HTTPClient]")
104
104
REQUIRE (payload == " redirect success" );
105
105
}
106
106
{
107
- // 302 redirect with follow disabled
107
+ // GET 302 redirect with follow disabled
108
108
WiFiClient client;
109
109
HTTPClient http;
110
110
String uri = String (" /redirect302?host=" )+getenv (" SERVER_IP" );
@@ -113,10 +113,10 @@ TEST_CASE("HTTP GET & POST requests", "[HTTPClient]")
113
113
REQUIRE (httpCode == 302 );
114
114
}
115
115
{
116
- // 307 redirect with follow enabled
116
+ // GET 307 redirect with strict RFC follow enabled
117
117
WiFiClient client;
118
118
HTTPClient http;
119
- http.setFollowRedirects (true );
119
+ http.setFollowRedirects (HTTPC_STRICT_FOLLOW_REDIRECTS );
120
120
String uri = String (" /redirect307?host=" )+getenv (" SERVER_IP" );
121
121
http.begin (client, getenv (" SERVER_IP" ), 8088 , uri.c_str ());
122
122
auto httpCode = http.GET ();
@@ -125,7 +125,7 @@ TEST_CASE("HTTP GET & POST requests", "[HTTPClient]")
125
125
REQUIRE (payload == " redirect success" );
126
126
}
127
127
{
128
- // 307 redirect with follow disabled
128
+ // GET 307 redirect with follow disabled
129
129
WiFiClient client;
130
130
HTTPClient http;
131
131
String uri = String (" /redirect307?host=" )+getenv (" SERVER_IP" );
@@ -134,31 +134,33 @@ TEST_CASE("HTTP GET & POST requests", "[HTTPClient]")
134
134
REQUIRE (httpCode == 307 );
135
135
}
136
136
{
137
- // 301 exceeding redirect limit
137
+ // GET 301 exceeding redirect limit
138
138
WiFiClient client;
139
139
HTTPClient http;
140
- http.setFollowRedirects (true );
140
+ http.setFollowRedirects (HTTPC_STRICT_FOLLOW_REDIRECTS );
141
141
http.setRedirectLimit (0 );
142
142
String uri = String (" /redirect301?host=" )+getenv (" SERVER_IP" );
143
143
http.begin (client, getenv (" SERVER_IP" ), 8088 , uri.c_str ());
144
144
auto httpCode = http.GET ();
145
145
REQUIRE (httpCode == 301 );
146
146
}
147
147
{
148
- // POST 303 redirect with follow enabled
148
+ // POST 303 redirect with strict RFC follow enabled
149
149
WiFiClient client;
150
150
HTTPClient http;
151
- http.setFollowRedirects (true );
151
+ http.setFollowRedirects (HTTPC_STRICT_FOLLOW_REDIRECTS );
152
152
http.begin (client, getenv (" SERVER_IP" ), 8088 , " /redirect303" );
153
153
auto httpCode = http.POST (getenv (" SERVER_IP" ));
154
154
REQUIRE (httpCode == HTTP_CODE_OK);
155
155
String payload = http.getString ();
156
156
REQUIRE (payload == " redirect success" );
157
+ // TODO: need check for dropping: redirection should use GET method
157
158
}
158
159
{
159
160
// POST 303 redirect with follow disabled
160
161
WiFiClient client;
161
162
HTTPClient http;
163
+ http.setFollowRedirects (HTTPC_DISABLE_FOLLOW_REDIRECTS);
162
164
http.begin (client, getenv (" SERVER_IP" ), 8088 , " /redirect303" );
163
165
auto httpCode = http.POST (getenv (" SERVER_IP" ));
164
166
REQUIRE (httpCode == 303 );
@@ -167,6 +169,7 @@ TEST_CASE("HTTP GET & POST requests", "[HTTPClient]")
167
169
// 302 redirect with follow disabled
168
170
WiFiClient client;
169
171
HTTPClient http;
172
+ http.setFollowRedirects (HTTPC_DISABLE_FOLLOW_REDIRECTS);
170
173
String uri = String (" /redirect302?host=" )+getenv (" SERVER_IP" );
171
174
http.begin (client, getenv (" SERVER_IP" ), 8088 , uri.c_str ());
172
175
auto httpCode = http.GET ();
0 commit comments