File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Release/samples/BingRequest Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,23 @@ using namespace web::http;
30
30
using namespace web ::http::client;
31
31
using namespace concurrency ::streams;
32
32
33
+ /* Can pass proxy information via environment variable http_proxy.
34
+ Example:
35
+ Linux: export http_proxy=http://192.1.8.1:8080
36
+ */
37
+ web::http::client::http_client_config client_config_for_proxy ()
38
+ {
39
+ web::http::client::http_client_config client_config;
40
+
41
+ if (const char * env_http_proxy = std::getenv (" http_proxy" )) {
42
+ web::web_proxy proxy (env_http_proxy);
43
+ client_config.set_proxy (proxy);
44
+ }
45
+
46
+ return client_config;
47
+ }
48
+
49
+
33
50
#ifdef _WIN32
34
51
int wmain (int argc, wchar_t *args[])
35
52
#else
@@ -52,7 +69,7 @@ int main(int argc, char *args[])
52
69
53
70
// Create an HTTP request.
54
71
// Encode the URI query since it could contain special characters like spaces.
55
- http_client client (U (" http://www.bing.com/" ));
72
+ http_client client (U (" http://www.bing.com/" ), client_config_for_proxy () );
56
73
return client.request (methods::GET, uri_builder (U (" /search" )).append_query (U (" q" ), searchTerm).to_string ());
57
74
})
58
75
@@ -74,4 +91,4 @@ int main(int argc, char *args[])
74
91
.wait ();
75
92
76
93
return 0 ;
77
- }
94
+ }
You can’t perform that action at this time.
0 commit comments