📄 curl_easy_setopt.3
字号:
\fICURLOPT_POSTFIELDS\fP to NULL or "" just effectively disables the sendingof the specified string. libcurl will instead assume that you'll send the POSTdata using the read callback!Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header.You can disable this header with \fICURLOPT_HTTPHEADER\fP as usual.To make multipart/formdata posts (aka rfc1867-posts), check out the\fICURLOPT_HTTPPOST\fP option..IP CURLOPT_POSTFIELDSIZEIf you want to post data to the server without letting libcurl do a strlen()to measure the data size, this option must be used. When this option is usedyou can post fully binary data, which otherwise is likely to fail. If thissize is set to -1, the library will use strlen() to get the size..IP CURLOPT_POSTFIELDSIZE_LARGEPass a curl_off_t as parameter. Use this to set the size of the\fICURLOPT_POSTFIELDS\fP data to prevent libcurl from doing strlen() on thedata to figure out the size. This is the large file version of the\fICURLOPT_POSTFIELDSIZE\fP option. (Added in 7.11.1).IP CURLOPT_COPYPOSTFIELDSPass a char * as parameter, which should be the full data to post in an HTTPPOST operation. It behaves as the \fICURLOPT_POSTFIELDS\fP option, but theoriginal data are copied by the library, allowing the application to overwritethe original data after setting this option.Because data are copied, care must be taken when using this option inconjunction with \fICURLOPT_POSTFIELDSIZE\fP or\fICURLOPT_POSTFIELDSIZE_LARGE\fP: If the size has not been set prior to\fICURLOPT_COPYPOSTFIELDS\fP, the data are assumed to be a NUL-terminatedstring; else the stored size informs the library about the data byte count tocopy. In any case, the size must not be changed after\fICURLOPT_COPYPOSTFIELDS\fP, unless another \fICURLOPT_POSTFIELDS\fP or\fICURLOPT_COPYPOSTFIELDS\fP option is issued.(Added in 7.17.1).IP CURLOPT_HTTPPOSTTells libcurl you want a multipart/formdata HTTP POST to be made and youinstruct what data to pass on to the server. Pass a pointer to a linked listof curl_httppost structs as parameter. . The easiest way to create such alist, is to use \fIcurl_formadd(3)\fP as documented. The data in this listmust remain intact until you close this curl handle again with\fIcurl_easy_cleanup(3)\fP.Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header.You can disable this header with \fICURLOPT_HTTPHEADER\fP as usual.When setting \fICURLOPT_HTTPPOST\fP, it will automatically set\fICURLOPT_NOBODY\fP to 0 (since 7.14.1)..IP CURLOPT_REFERERPass a pointer to a zero terminated string as parameter. It will be used toset the Referer: header in the http request sent to the remote server. Thiscan be used to fool servers or scripts. You can also set any custom headerwith \fICURLOPT_HTTPHEADER\fP..IP CURLOPT_USERAGENTPass a pointer to a zero terminated string as parameter. It will be used toset the User-Agent: header in the http request sent to the remote server. Thiscan be used to fool servers or scripts. You can also set any custom headerwith \fICURLOPT_HTTPHEADER\fP..IP CURLOPT_HTTPHEADERPass a pointer to a linked list of HTTP headers to pass to the server in yourHTTP request. The linked list should be a fully valid list of \fBstructcurl_slist\fP structs properly filled in. Use \fIcurl_slist_append(3)\fP tocreate the list and \fIcurl_slist_free_all(3)\fP to clean up an entirelist. If you add a header that is otherwise generated and used by libcurlinternally, your added one will be used instead. If you add a header with nocontents as in 'Accept:' (no data on the right side of the colon), theinternally used header will get disabled. Thus, using this option you can addnew headers, replace internal headers and remove internal headers. To add aheader with no contents, make the contents be two quotes: \&"". The headersincluded in the linked list must not be CRLF-terminated, because curl addsCRLF after each header item. Failure to comply with this will result instrange bugs because the server will most likely ignore part of the headersyou specified.The first line in a request (containing the method, usually a GET or POST) isnot a header and cannot be replaced using this option. Only the linesfollowing the request-line are headers. Adding this method line in this listof headers will only cause your request to send an invalid header.Pass a NULL to this to reset back to no custom headers.The most commonly replaced headers have "shortcuts" in the options\fICURLOPT_COOKIE\fP, \fICURLOPT_USERAGENT\fP and \fICURLOPT_REFERER\fP..IP CURLOPT_HTTP200ALIASESPass a pointer to a linked list of aliases to be treated as valid HTTP 200responses. Some servers respond with a custom header response line. Forexample, IceCast servers respond with "ICY 200 OK". By including this stringin your list of aliases, the response will be treated as a valid HTTP headerline such as "HTTP/1.0 200 OK". (Added in 7.10.3)The linked list should be a fully valid list of struct curl_slist structs, andbe properly filled in. Use \fIcurl_slist_append(3)\fP to create the list and\fIcurl_slist_free_all(3)\fP to clean up an entire list.The alias itself is not parsed for any version strings. Before libcurl 7.16.3,Libcurl used the value set by option \fICURLOPT_HTTP_VERSION\fP, but startingwith 7.16.3 the protocol is assumed to match HTTP 1.0 when an alias matched..IP CURLOPT_COOKIEPass a pointer to a zero terminated string as parameter. It will be used toset a cookie in the http request. The format of the string should beNAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookieshould contain.If you need to set multiple cookies, you need to set them all using a singleoption and thus you need to concatenate them all in one single string. Setmultiple cookies in one string like this: "name1=content1; name2=content2;"etc.Using this option multiple times will only make the latest string override theprevious ones..IP CURLOPT_COOKIEFILEPass a pointer to a zero terminated string as parameter. It should contain thename of your file holding cookie data to read. The cookie data may be inNetscape / Mozilla cookie data format or just regular HTTP-style headersdumped to a file.Given an empty or non-existing file or by passing the empty string (""), thisoption will enable cookies for this curl handle, making it understand andparse received cookies and then use matching cookies in future request.If you use this option multiple times, you just add more files to read.Subsequent files will add more cookies..IP CURLOPT_COOKIEJARPass a file name as char *, zero terminated. This will make libcurl write allinternally known cookies to the specified file when \fIcurl_easy_cleanup(3)\fPis called. If no cookies are known, no file will be created. Specify "-" toinstead have the cookies written to stdout. Using this option also enablescookies for this session, so if you for example follow a location it will makematching cookies get sent accordingly.If the cookie jar file can't be created or written to (when the\fIcurl_easy_cleanup(3)\fP is called), libcurl will not and cannot report anerror for this. Using \fICURLOPT_VERBOSE\fP or \fICURLOPT_DEBUGFUNCTION\fPwill get a warning to display, but that is the only visible feedback you getabout this possibly lethal situation..IP CURLOPT_COOKIESESSIONPass a long set to non-zero to mark this as a new cookie "session". It willforce libcurl to ignore all cookies it is about to load that are "sessioncookies" from the previous session. By default, libcurl always stores andloads all cookies, independent if they are session cookies are not. Sessioncookies are cookies without expiry date and they are meant to be alive andexisting for this "session" only..IP CURLOPT_COOKIELISTPass a char * to a cookie string. Cookie can be either in Netscape / Mozillaformat or just regular HTTP-style header (Set-Cookie: ...) format. If cURLcookie engine was not enabled it will enable its cookie engine. Passing amagic string \&"ALL" will erase all cookies known by cURL. (Added in 7.14.1)Passing the special string \&"SESS" will only erase all session cookies knownby cURL. (Added in 7.15.4) Passing the special string \&"FLUSH" will writeall cookies known by cURL to the file specified by \fICURLOPT_COOKIEJAR\fP.(Added in 7.17.1).IP CURLOPT_HTTPGETPass a long. If the long is non-zero, this forces the HTTP request to get backto GET. usable if a POST, HEAD, PUT or a custom request have been usedpreviously using the same curl handle.When setting \fICURLOPT_HTTPGET\fP to a non-zero value, it will automaticallyset \fICURLOPT_NOBODY\fP to 0 (since 7.14.1)..IP CURLOPT_HTTP_VERSIONPass a long, set to one of the values described below. They force libcurl touse the specific HTTP versions. This is not sensible to do unless you have agood reason..RS.IP CURL_HTTP_VERSION_NONEWe don't care about what version the library uses. libcurl will use whateverit thinks fit..IP CURL_HTTP_VERSION_1_0Enforce HTTP 1.0 requests..IP CURL_HTTP_VERSION_1_1Enforce HTTP 1.1 requests..RE.IP CURLOPT_IGNORE_CONTENT_LENGTHIgnore the Content-Length header. This is useful for Apache 1.x (and similarservers) which will report incorrect content length for files over 2gigabytes. If this option is used, curl will not be able to accurately reportprogress, and will simply stop the download when the server ends theconnection. (added in 7.14.1).IP CURLOPT_HTTP_CONTENT_DECODINGPass a long to tell libcurl how to act on content decoding. If set to zero,content decoding will be disabled. If set to 1 it is enabled. Note howeverthat libcurl has no default content decoding but requires you to use\fICURLOPT_ENCODING\fP for that. (added in 7.16.2).IP CURLOPT_HTTP_TRANSFER_DECODINGPass a long to tell libcurl how to act on transfer decoding. If set to zero,transfer decoding will be disabled, if set to 1 it is enabled(default). libcurl does chunked transfer decoding by default unless thisoption is set to zero. (added in 7.16.2).SH FTP OPTIONS.IP CURLOPT_FTPPORTPass a pointer to a zero terminated string as parameter. It will be used toget the IP address to use for the ftp PORT instruction. The PORT instructiontells the remote server to connect to our specified IP address. The string maybe a plain IP address, a host name, an network interface name (under Unix) orjust a '-' letter to let the library use your systems default IPaddress. Default FTP operations are passive, and thus won't use PORT.You disable PORT again and go back to using the passive version by settingthis option to NULL..IP CURLOPT_QUOTEPass a pointer to a linked list of FTP or SFTP commands to pass tothe server prior to your ftp request. This will be done before anyother commands are issued (even before the CWD command for FTP). Thelinked list should be a fully valid list of 'struct curl_slist' structsproperly filled in with text strings. Use \fIcurl_slist_append(3)\fPto append strings (commands) to the list, and clear the entire listafterwards with \fIcurl_slist_free_all(3)\fP. Disable this operationagain by setting a NULL to this option.The valid SFTP commands are: chgrp, chmod, chown, ln, mkdir, pwd,rename, rm, rmdir, symlink. (SFTP support added in 7.16.3).IP CURLOPT_POSTQUOTEPass a pointer to a linked list of FTP or SFTP commands to pass to theserver after your ftp transfer request. The linked list should be afully valid list of struct curl_slist structs properly filled in asdescribed for \fICURLOPT_QUOTE\fP. Disable this operation again bysetting a NULL to this option..IP CURLOPT_PREQUOTEPass a pointer to a linked list of FTP commands to pass to the server afterthe transfer type is set. The linked list should be a fully valid list ofstruct curl_slist structs properly filled in as described for\fICURLOPT_QUOTE\fP. Disable this operation again by setting a NULL to thisoption. Before version 7.15.6, if you also set \fICURLOPT_NOBODY\fP non-zero,this option didn't work..IP CURLOPT_DIRLISTONLYA non-zero parameter tells the library to just list the names of files in adirectory, instead of doing a full directory listing that would include filesizes, dates etc. This works for FTP and SFTP URLs.This causes an FTP NLST command to be sent on an FTP server. Bewarethat some FTP servers list only files in their response to NLST; theymight not include subdirectories and symbolic links.(This option was known as CURLOPT_FTPLISTONLY up to 7.16.4).IP CURLOPT_APPENDA non-zero parameter tells the library to append to the remote file instead ofoverwrite it. This is only useful when uploading to an ftp site.(This option was known as CURLOPT_FTPAPPEND up to 7.16.4).IP CURLOPT_FTP_USE_EPRTPass a long. If the value is non-zero, it tells curl to use the EPRT (andLPRT) command when doing active FTP downloads (which is enabled by\fICURLOPT_FTPPORT\fP). Using EPRT means that it will first attempt to useEPRT and then LPRT before using PORT, but if you pass FALSE (zero) to thisoption, it will not try using EPRT or LPRT, only plain PORT. (Added in 7.10.5)If the server is an IPv6 host, this option will have no effect as of 7.12.3..IP CURLOPT_FTP_USE_EPSVPass a long. If the value is non-zero, it tells curl to use the EPSV commandwhen doing passive FTP downloads (which it always does by default). Using EPSVmeans that it will first attempt to use EPSV before using PASV, but if you
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -