Movatterモバイル変換


[0]ホーム

URL:


API Overview
Docs
API: easyAPI: multiAPI: shareAPI: URLAPI: WebSocketEnvironment varsErrorsExamplesSecuritySymbolsTutorial
easy setopt optionseasy getinfo optionsmulti setopt optionsTLS options
Functions
All functionscurl_easy_getinfocurl_easy_initcurl_easy_performcurl_easy_resetcurl_easy_setoptcurl_multi_add_handlecurl_multi_initcurl_multi_performcurl_multi_remove_handlecurl_multi_setopt
curl /libcurl /API /Examples

libcurl - small example snippets

Related:
All functions
API
Symbols

A collection of smaller stand-alone applications using the libcurl API indifferent ways to show how to use it for different Internet transferscenarios.

Download all examples

You can also see a list of alllibcurl easy options and which example source codes that use them.

All examples are written in C, unless specifically mentioned.

Index of examples

10-at-a-timeDownload many files in parallel, in the same thread.
address-scopeHTTP GET to an IPv6 address with specific scope
altsvcHTTP with Alt-Svc support
anyauthputHTTP PUT upload with authentication using "any" method. libcurl picks the one the server supports/wants.
block_ipShow how CURLOPT_OPENSOCKETFUNCTION can be used to block IP addresses.
cacertinmemCA cert in memory with OpenSSL to get an HTTPS page.
certinfoExtract lots of TLS certificate info.
chkspeedShow transfer timing info after download completes.
connect-toUse CURLOPT_CONNECT_TO to connect to "wrong" hostname
cookie_interfaceImport and export cookies with COOKIELIST.
crawlerWeb crawler based on curl and libxml2 to stress-test curl with hundreds of concurrent connections to various servers.
debugShow how CURLOPT_DEBUGFUNCTION can be used.
default-schemeChange default scheme when none is provided in the URL
ephiperfifomulti socket API usage with epoll and timerfd
evhiperfifomulti socket interface together with libev
externalsocketPass in a custom socket for libcurl to use.
fileuploadUpload to a file:// URL
ftp-wildcardFTP wildcard pattern matching
ftpgetGet a single file from an FTP server.
ftpgetinfoChecks a single file's size and mtime from an FTP server.
ftpgetrespSimilar to ftpget.c but also stores the received response-lines in a separate file using our own callback!
ftpsgetGet a single file from an FTPS server.
ftpuploadPerforms an FTP upload and renames the file just after a successful transfer.
ftpuploadfrommemFTP upload a file from memory
ftpuploadresumeUpload to FTP, resuming failed transfers. Active mode.
getinfoUse getinfo to get content-type after completed transfer.
getinmemoryShows how the write callback function can be used to download data into a chunk of memory instead of storing it in a file.
getredirectShow how to extract Location: header and URL to redirect to.
getreferrerShow how to extract referrer header.
ghipermulti socket API usage together with glib2
headerapiExtract headers post transfer with the header API
hiperfifomulti socket API usage with libevent 2
href_extractorUses the "Streaming HTML parser" to extract the href pieces in a streaming manner from a downloaded HTML.
hsts-preloadPreload domains to HSTS
htmltidyDownload a document and use libtidy to parse the HTML.
htmltitle (C++)Get a web page, extract the title with libxml.
http-optionsIssue an HTTP 'OPTIONS *' request
http-postsimple HTTP POST using the easy interface
http2-downloadMultiplexed HTTP/2 downloads over a single connection
http2-pushinmemoryHTTP/2 server push. Receive all data in memory.
http2-serverpushHTTP/2 server push
http2-uploadMultiplexed HTTP/2 uploads over a single connection
http3Very simple HTTP/3 GET
http3-presentChecks if HTTP/3 support is present in libcurl.
httpcustomheaderHTTP request with custom modified, removed and added headers
httpputHTTP PUT with easy interface and read callback
httpput-postfieldsHTTP PUT using CURLOPT_POSTFIELDS
httpsSimple HTTPS GET
imap-appendSend email with IMAP
imap-authzidRetrieve emails from a shared IMAP mailbox
imap-copyCopy an email from one IMAP folder to another
imap-createCreate a new IMAP folder
imap-deleteDelete an IMAP folder
imap-examineObtain information about an IMAP folder
imap-fetchRetrieve IMAP emails
imap-listList the folders within an IMAP mailbox
imap-lsubList the subscribed IMAP folders
imap-multiGet IMAP email with the multi interface
imap-noopPerform an IMAP noop
imap-searchSearch for new IMAP emails
imap-sslIMAP with implicit SSL
imap-storeModify the properties of an email over IMAP
imap-tlsIMAP using TLS
interfaceUse CURLOPT_INTERFACE to bind the outgoing socket to an interface
ipv6HTTPS GET using IPv6 only
keepaliveUse the TCP keep-alive options
localportUse CURLOPT_LOCALPORT to control local port number
maxconnectsSet maximum number of persistent connections to 1.
multi-appA basic application source code using the multi interface doing two transfers in parallel.
multi-debugcallbackmulti interface and debug callback
multi-doublemulti interface code doing two parallel HTTP transfers
multi-eventmulti_socket API using libevent
multi-formaddusing the multi interface to do a multipart formpost without blocking
multi-legacyA basic application source code using the multi interface doing two transfers in parallel without curl_multi_wait/poll.
multi-postusing the multi interface to do a multipart formpost without blocking
multi-singleusing the multi interface to do a single download
multi-uvmulti_socket API using libuv
multithreadA multi-threaded program using pthreads to fetch several files at once
netrcUse credentials from .netrc
parseurlBasic URL API use.
persistentreusing handles to do HTTP persistent connections
pop3-authzidRetrieve emails from a shared POP3 mailbox
pop3-deleDelete POP3 emails
pop3-listList the contents of a POP3 mailbox
pop3-multiGet POP3 email using the multi interface
pop3-noopPerform a POP3 noop
pop3-retrRetrieve POP3 email
pop3-sslGet POP3 email using implicit SSL
pop3-statObtain POP3 message statistics
pop3-tlsPOP3 using TLS
pop3-topPOP3 example showing how to retrieve only the headers of an email
pop3-uidlList the contents of a POP3 mailbox by unique ID
post-callbackIssue an HTTP POST and provide the data through the read callback.
postinmemoryMake an HTTP POST with data from memory and receive response in memory.
postit2HTTP Multipart formpost with file upload and two additional parts.
postit2-formaddHTTP Multipart formpost with file upload and two additional parts.
progressfuncUse the progress callbacks, old and/or new one depending on available libcurl version.
protofeatsOutputs all protocols and features supported
rangeGET a range only of an HTTP resource
resolveUse CURLOPT_RESOLVE to feed custom IP addresses for given hostname + port number combinations.
rtsp-optionsVery simple RTSP request sending OPTIONS.
sendrecvDemonstrate curl_easy_send() and curl_easy_recv() usage.
sepheadersSimple HTTP GET that stores the headers in a separate file
sessioninfoUses the CURLINFO_TLS_SESSION data.
sftpgetGets a file using an SFTP URL.
sftpuploadresumeUpload to SFTP, resuming a previously aborted transfer.
shared-connection-cacheConnection cache shared between easy handles with the share interface
simpleVery simple HTTP GET
simplepostVery simple HTTP POST
simplesslShows HTTPS usage with client certs and optional ssl engine use.
smooth-gtk-threadA multi threaded application that uses a progress bar to show status. It uses Gtk+ to make a smooth pulse.
smtp-authzidSend email on behalf of another user with SMTP
smtp-expnExpand an SMTP email mailing list
smtp-mailSend email with SMTP
smtp-mimeSend SMTP mime emails
smtp-multiSend SMTP email with the multi interface
smtp-sslSend SMTP email using implicit SSL
smtp-tlsSend SMTP email using implicit TLS
smtp-vrfyVerify an SMTP email address
sslbackendShows HTTPS usage with client certs and optional ssl engine use.
synctimeSet your system time from a remote HTTP server's Date: header.
threaded-sslShow the required mutex callback setups for GnuTLS and OpenSSL when using libcurl multi-threaded.
unixsocketAccess HTTP server over Unix domain socket
url2fileDownload a given URL into a local file named page.out.
urlapiSet working URL with CURLU *.
usercertinmemUse an in-memory user certificate and RSA key and retrieve an https page.
websocketWebSocket using CONNECT_ONLY
websocket-cbWebSocket download-only using write callback
xmlstreamStream-parse a document using the streaming Expat parser.

You also find these examples in the distribution archive, indocs/examples.


[8]ページ先頭

©2009-2025 Movatter.jp