📄 url.c
字号:
break; case CURLOPT_PROXYAUTH: /* * Set HTTP Authentication type BITMASK. */ { long auth = va_arg(param, long); /* switch off bits we can't support */#ifndef USE_SSLEAY auth &= ~CURLAUTH_NTLM; /* no NTLM without SSL */#endif#ifndef HAVE_GSSAPI auth &= ~CURLAUTH_GSSNEGOTIATE; /* no GSS-Negotiate without GSSAPI */#endif if(!auth) return CURLE_FAILED_INIT; /* no supported types left! */ data->set.proxyauth = auth; } break; case CURLOPT_USERPWD: /* * user:password to use in the operation */ data->set.userpwd = va_arg(param, char *); break; case CURLOPT_POSTQUOTE: /* * List of RAW FTP commands to use after a transfer */ data->set.postquote = va_arg(param, struct curl_slist *); break; case CURLOPT_PREQUOTE: /* * List of RAW FTP commands to use prior to RETR (Wesley Laxton) */ data->set.prequote = va_arg(param, struct curl_slist *); break; case CURLOPT_QUOTE: /* * List of RAW FTP commands to use before a transfer */ data->set.quote = va_arg(param, struct curl_slist *); break; case CURLOPT_PROGRESSFUNCTION: /* * Progress callback function */ data->set.fprogress = va_arg(param, curl_progress_callback); if(data->set.fprogress) data->progress.callback = TRUE; /* no longer internal */ else data->progress.callback = FALSE; /* NULL enforces internal */ break; case CURLOPT_PROGRESSDATA: /* * Custom client data to pass to the progress callback */ data->set.progress_client = va_arg(param, void *); break; case CURLOPT_PROXYUSERPWD: /* * user:password needed to use the proxy */ data->set.proxyuserpwd = va_arg(param, char *); break; case CURLOPT_RANGE: /* * What range of the file you want to transfer */ data->set.set_range = va_arg(param, char *); break; case CURLOPT_RESUME_FROM: /* * Resume transfer at the give file position */ data->set.set_resume_from = va_arg(param, long); break; case CURLOPT_DEBUGFUNCTION: /* * stderr write callback. */ data->set.fdebug = va_arg(param, curl_debug_callback); /* * if the callback provided is NULL, it'll use the default callback */ break; case CURLOPT_DEBUGDATA: /* * Set to a void * that should receive all error writes. This * defaults to CURLOPT_STDERR for normal operations. */ data->set.debugdata = va_arg(param, void *); break; case CURLOPT_STDERR: /* * Set to a FILE * that should receive all error writes. This * defaults to stderr for normal operations. */ data->set.err = va_arg(param, FILE *); if(!data->set.err) data->set.err = stderr; break; case CURLOPT_HEADERFUNCTION: /* * Set header write callback */ data->set.fwrite_header = va_arg(param, curl_write_callback); break; case CURLOPT_WRITEFUNCTION: /* * Set data write callback */ data->set.fwrite = va_arg(param, curl_write_callback); if(!data->set.fwrite) /* When set to NULL, reset to our internal default function */ data->set.fwrite = (curl_write_callback)fwrite; break; case CURLOPT_READFUNCTION: /* * Read data callback */ data->set.fread = va_arg(param, curl_read_callback); if(!data->set.fread) /* When set to NULL, reset to our internal default function */ data->set.fread = (curl_read_callback)fread; break; case CURLOPT_SSLCERT: /* * String that holds file name of the SSL certificate to use */ data->set.cert = va_arg(param, char *); break; case CURLOPT_SSLCERTTYPE: /* * String that holds file type of the SSL certificate to use */ data->set.cert_type = va_arg(param, char *); break; case CURLOPT_SSLKEY: /* * String that holds file name of the SSL certificate to use */ data->set.key = va_arg(param, char *); break; case CURLOPT_SSLKEYTYPE: /* * String that holds file type of the SSL certificate to use */ data->set.key_type = va_arg(param, char *); break; case CURLOPT_SSLKEYPASSWD: /* * String that holds the SSL private key password. */ data->set.key_passwd = va_arg(param, char *); break; case CURLOPT_SSLENGINE: /* * String that holds the SSL crypto engine. */#ifdef HAVE_OPENSSL_ENGINE_H { const char *cpTemp = va_arg(param, char *); ENGINE *e; if (cpTemp && cpTemp[0]) { e = ENGINE_by_id(cpTemp); if (e) { if (data->engine) { ENGINE_free(data->engine); } data->engine = e; } else { failf(data, "SSL Engine '%s' not found", cpTemp); return CURLE_SSL_ENGINE_NOTFOUND; } } }#else return CURLE_SSL_ENGINE_NOTFOUND;#endif break; case CURLOPT_SSLENGINE_DEFAULT: /* * flag to set engine as default. */#ifdef HAVE_OPENSSL_ENGINE_H if (data->engine) { if (ENGINE_set_default(data->engine, ENGINE_METHOD_ALL) > 0) {#ifdef DEBUG fprintf(stderr,"set default crypto engine\n");#endif } else {#ifdef DEBUG failf(data, "set default crypto engine failed");#endif return CURLE_SSL_ENGINE_SETFAILED; } }#endif break; case CURLOPT_CRLF: /* * Kludgy option to enable CRLF convertions. Subject for removal. */ data->set.crlf = va_arg(param, long)?TRUE:FALSE; break; case CURLOPT_INTERFACE: /* * Set what interface to bind to when performing an operation and thus * what from-IP your connection will use. */ data->set.device = va_arg(param, char *); break; case CURLOPT_KRB4LEVEL: /* * A string that defines the krb4 security level. */ data->set.krb4_level = va_arg(param, char *); data->set.krb4=data->set.krb4_level?TRUE:FALSE; break; case CURLOPT_SSL_VERIFYPEER: /* * Enable peer SSL verifying. */ data->set.ssl.verifypeer = va_arg(param, long); break; case CURLOPT_SSL_VERIFYHOST: /* * Enable verification of the CN contained in the peer certificate */ data->set.ssl.verifyhost = va_arg(param, long); break; case CURLOPT_SSL_CTX_FUNCTION: /* * Set a SSL_CTX callback */ data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback); break; case CURLOPT_SSL_CTX_DATA: /* * Set a SSL_CTX callback parameter pointer */ data->set.ssl.fsslctxp = va_arg(param, void *); break; case CURLOPT_CAINFO: /* * Set CA info for SSL connection. Specify file name of the CA certificate */ data->set.ssl.CAfile = va_arg(param, char *); break; case CURLOPT_CAPATH: /* * Set CA path info for SSL connection. Specify directory name of the CA * certificates which have been prepared using openssl c_rehash utility. */ /* This does not work on windows. */ data->set.ssl.CApath = va_arg(param, char *); break; case CURLOPT_TELNETOPTIONS: /* * Set a linked list of telnet options */ data->set.telnet_options = va_arg(param, struct curl_slist *); break; case CURLOPT_BUFFERSIZE: /* * The application kindly asks for a differently sized receive buffer. * If it seems reasonable, we'll use it. */ data->set.buffer_size = va_arg(param, long); if((data->set.buffer_size> (BUFSIZE -1 )) || (data->set.buffer_size < 1)) data->set.buffer_size = 0; /* huge internal default */ break; case CURLOPT_NOSIGNAL: /* * The application asks not to set any signal() or alarm() handlers, * even when using a timeout. */ data->set.no_signal = va_arg(param, long) ? TRUE : FALSE; break; case CURLOPT_SHARE: { struct Curl_share *set; set = va_arg(param, struct Curl_share *); /* disconnect from old share, if any */ if(data->share) { Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE); if(data->share->hostcache == data->hostcache) data->hostcache = NULL; if(data->share->cookies == data->cookies) data->cookies = NULL; data->share->dirty--; Curl_share_unlock(data, CURL_LOCK_DATA_SHARE); data->share = NULL; } /* use new share if it set */ data->share = set; if(data->share) { Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE); data->share->dirty++; if(data->share->hostcache) { /* use shared host cache, first free own one if any */ if(data->hostcache) Curl_hash_destroy(data->hostcache); data->hostcache = data->share->hostcache; } if(data->share->cookies) { /* use shared cookie list, first free own one if any */ if (data->cookies) Curl_cookie_cleanup(data->cookies); data->cookies = data->share->cookies; } Curl_share_unlock(data, CURL_LOCK_DATA_SHARE); } /* check cookie list is set */ if(!data->cookies) data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE ); /* check for host cache not needed, * it will be done by curl_easy_perform */ } break; case CURLOPT_PROXYTYPE: /* * Set proxy type. HTTP/SOCKS4/SOCKS5 */ data->set.proxytype = va_arg(param, long); break; case CURLOPT_PRIVATE: /* * Set private data pointer. */ data->set.private = va_arg(param, char *); break; case CURLOPT_HTTP200ALIASES: /* * Set a list of aliases for HTTP 200 in response header */ data->set.http200aliases = va_arg(param, struct curl_slist *); break; case CURLOPT_MAXFILESIZE: /* * Set the maximum size of a file to download. */ data->set.max_filesize = va_arg(param, long); break; default: /* unknown tag and its companion, just ignore: */ return CURLE_FAILED_INIT; /* correct this */ } return CURLE_OK;}CURLcode Curl_disconnect(struct connectdata *conn){ if(!conn) return CURLE_OK; /* this is closed and fine already */ /* * The range string is usually freed in curl_done(), but we might * get here *instead* if we fail prematurely. Thus we need to be able * to free this resource here as well. */ if(conn->bits.rangestringalloc) { free(conn->range); conn->bits.rangestringalloc = FALSE; } if((conn->ntlm.state != NTLMSTATE_NONE) || (conn->proxyntlm.state != NTLMSTATE_NONE)) /* Authentication data is a mix of connection-related and sessionhandle- related stuff. NTLM is connection-related so when we close the shop we shall forget. */ conn->data->state.authstage = 0; if(-1 != conn->connectindex) { /* unlink ourselves! */ infof(conn->data, "Closing connection #%d\n", conn->connectindex); conn->data->state.connects[conn->connectindex] = NULL; } if(conn->curl_disconnect) /* This is set if protocol-specific cleanups should be made */ conn->curl_disconnect(conn); Curl_safefree(conn->proto.generic); Curl_safefree(conn->newurl); Curl_safefree(conn->path); /* the URL path part */#ifdef USE_SSLEAY Curl_SSL_Close(conn);#endif /* USE_SSLEAY */ /* close possibly still open sockets */ if(-1 != conn->secondarysocket) sclose(conn->secondarysocket); if(-1 != conn->firstsocket) sclose(conn->firstsocket); Curl_safefree(conn->user); Curl_safefree(conn->passwd); Curl_safefree(conn->proxyuser); Curl_safefree(conn->proxypasswd); Curl_safefree(conn->allocptr.proxyuserpwd);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -