CURLOPT_PROXYAUTH.md (1857B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_PROXYAUTH 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_HTTPAUTH (3) 9 - CURLOPT_PROXY (3) 10 - CURLOPT_PROXYPORT (3) 11 - CURLOPT_PROXYTYPE (3) 12 - CURLOPT_PROXYUSERPWD (3) 13 Protocol: 14 - All 15 Added-in: 7.10.7 16 --- 17 18 # NAME 19 20 CURLOPT_PROXYAUTH - HTTP proxy authentication methods 21 22 # SYNOPSIS 23 24 ~~~c 25 #include <curl/curl.h> 26 27 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXYAUTH, long bitmask); 28 ~~~ 29 30 # DESCRIPTION 31 32 Pass a long as parameter, which is set to a bitmask, to tell libcurl which 33 HTTP authentication method(s) you want it to use for your proxy 34 authentication. If more than one bit is set, libcurl first queries the site to 35 see what authentication methods it supports and then it picks the best one you 36 allow it to use. For some methods, this induces an extra network round-trip. 37 Set the actual name and password with the CURLOPT_PROXYUSERPWD(3) 38 option. 39 40 The bitmask can be constructed by the bits listed and described in the 41 CURLOPT_HTTPAUTH(3) man page. 42 43 # DEFAULT 44 45 CURLAUTH_BASIC 46 47 # %PROTOCOLS% 48 49 # EXAMPLE 50 51 ~~~c 52 int main(void) 53 { 54 CURL *curl = curl_easy_init(); 55 if(curl) { 56 CURLcode ret; 57 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); 58 /* use this proxy */ 59 curl_easy_setopt(curl, CURLOPT_PROXY, "http://local.example.com:1080"); 60 /* allow whatever auth the proxy speaks */ 61 curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY); 62 /* set the proxy credentials */ 63 curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "james:007"); 64 ret = curl_easy_perform(curl); 65 curl_easy_cleanup(curl); 66 } 67 } 68 ~~~ 69 70 # %AVAILABILITY% 71 72 # RETURN VALUE 73 74 curl_easy_setopt(3) returns a CURLcode indicating success or error. 75 76 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 77 libcurl-errors(3).