Skip to content

Commit 1491eb4

Browse files
committed
setTimeout method has been added
1 parent 0af9372 commit 1491eb4

File tree

3 files changed

+158
-113
lines changed

3 files changed

+158
-113
lines changed

examples/main.cpp

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,21 @@ void ignoreSslErrors()
187187
std::cout << "Data: " << response.textData << std::endl;
188188
}
189189

190+
void setTimeout()
191+
{
192+
HttpRequest httpRequest("https://httpstat.us/504?sleep=10000");
193+
194+
// You can set the timeout in seconds
195+
auto response = httpRequest
196+
.setTimeout(3) // 3 sec
197+
.send()
198+
.get();
199+
200+
std::cout << "Succeed: " << response.succeed << std::endl;
201+
std::cout << "Http Status Code: " << response.statusCode << std::endl;
202+
std::cout << "Error Message: " << response.errorMessage << std::endl;
203+
}
204+
190205
void setDownloadAndUploadBandwidthLimit()
191206
{
192207
HttpRequest httpRequest("https://httpbun.com/get");
@@ -206,29 +221,31 @@ void setDownloadAndUploadBandwidthLimit()
206221

207222
int main()
208223
{
209-
simpleGet();
210-
211-
nonBlockingGet();
212-
213-
receiveBinaryData();
214-
215-
receiveError();
216-
217-
sendingHttpHeaders();
218-
219-
simplePostWithFormData();
220-
221-
simplePostWithJSONData();
222-
223-
simplePutWithFormData();
224-
225-
simpleDeleteWithFormData();
226-
227-
simplePatch();
228-
229-
ignoreSslErrors();
230-
231-
setDownloadAndUploadBandwidthLimit();
224+
// simpleGet();
225+
//
226+
// nonBlockingGet();
227+
//
228+
// receiveBinaryData();
229+
//
230+
// receiveError();
231+
//
232+
// sendingHttpHeaders();
233+
//
234+
// simplePostWithFormData();
235+
//
236+
// simplePostWithJSONData();
237+
//
238+
// simplePutWithFormData();
239+
//
240+
// simpleDeleteWithFormData();
241+
//
242+
// simplePatch();
243+
//
244+
// ignoreSslErrors();
245+
246+
setTimeout();
247+
248+
// setDownloadAndUploadBandwidthLimit();
232249

233250
return 0;
234251
}

0 commit comments

Comments
 (0)