⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 internals

📁 harvest是一个下载html网页得机器人
💻
📖 第 1 页 / 共 2 页
字号:
 base64-functions for user+password stuff (and more) is in (lib/base64.c) and all functions for parsing and sending cookies are found in (lib/cookie.c). HTTPS uses in almost every means the same procedure as HTTP, with only two exceptions: the connect procedure is different and the function used to read or write from the socket is different, although the latter fact is hidden in the source by the use of curl_read() for reading and curl_write() for writing data to the remote server. http_chunks.c contains functions that understands HTTP 1.1 chunked transfer encoding. An interesting detail with the HTTP(S) request, is the add_buffer() series of functions we use. They append data to one single buffer, and when the building is done the entire request is sent off in one single write. This is done this way to overcome problems with flawed firewalls and lame servers. FTP The Curl_if2ip() function can be used for getting the IP number of a specified network interface, and it resides in lib/if2ip.c. Curl_ftpsendf() is used for sending FTP commands to the remote server. It was made a separate function to prevent us programmers from forgetting that they must be CRLF terminated. They must also be sent in one single write() to make firewalls and similar happy. Kerberos The kerberos support is mainly in lib/krb4.c and lib/security.c. TELNET Telnet is implemented in lib/telnet.c. FILE The file:// protocol is dealt with in lib/file.c. LDAP Everything LDAP is in lib/ldap.c. GENERAL URL encoding and decoding, called escaping and unescaping in the source code, is found in lib/escape.c. While transfering data in Transfer() a few functions might get used. curl_getdate() in lib/getdate.c is for HTTP date comparisons (and more). lib/getenv.c offers curl_getenv() which is for reading environment variables in a neat platform independent way. That's used in the client, but also in lib/url.c when checking the proxy environment variables. Note that contrary to the normal unix getenv(), this returns an allocated buffer that must be free()ed after use. lib/netrc.c holds the .netrc parser lib/timeval.c features replacement functions for systems that don't have gettimeofday() and a few support functions for timeval convertions.  A function named curl_version() that returns the full curl version string is found in lib/version.c. If authentication is requested but no password is given, a getpass_r() clone exists in lib/getpass.c. libcurl offers a custom callback that can be used instead of this, but it doesn't change much to us.Persistent Connections====================== The persistent connection support in libcurl requires some considerations on how to do things inside of the library. o The 'SessionHandle' struct returned in the curl_easy_init() call must never   hold connection-oriented data. It is meant to hold the root data as well as   all the options etc that the library-user may choose. o The 'SessionHandle' struct holds the "connection cache" (an array of   pointers to 'connectdata' structs). There's one connectdata struct   allocated for each connection that libcurl knows about. o This also enables the 'curl handle' to be reused on subsequent transfers,   something that was illegal before libcurl 7.7. o When we are about to perform a transfer with curl_easy_perform(), we first   check for an already existing connection in the cache that we can use,   otherwise we create a new one and add to the cache. If the cache is full   already when we add a new connection, we close one of the present ones. We   select which one to close dependent on the close policy that may have been   previously set. o When the transfer operation is complete, we try to leave the connection   open. Particular options may tell us not to, and protocols may signal   closure on connections and then we don't keep it open of course. o When curl_easy_cleanup() is called, we close all still opened connections. You do realize that the curl handle must be re-used in order for the persistent connections to work.Library Symbols===============  All symbols used internally in libcurl must use a 'Curl_' prefix if they're used in more than a single file. Single-file symbols must be made static. Public ("exported") symbols must use a 'curl_' prefix. (There are exceptions, but they are to be changed to follow this pattern in future versions.)Return Codes and Informationals=============================== I've made things simple. Almost every function in libcurl returns a CURLcode, that must be CURLE_OK if everything is OK or otherwise a suitable error code as the curl/curl.h include file defines. The very spot that detects an error must use the Curl_failf() function to set the human-readable error description. In aiding the user to understand what's happening and to debug curl usage, we must supply a fair amount of informational messages by using the Curl_infof() function. Those messages are only displayed when the user explicitly asks for them. They are best used when revealing information that isn't otherwise obvious.Client====== main() resides in src/main.c together with most of the client code. src/hugehelp.c is automatically generated by the mkhelp.pl perl script to display the complete "manual" and the src/urlglob.c file holds the functions used for the URL-"globbing" support. Globbing in the sense that the {} and [] expansion stuff is there. The client mostly messes around to setup its 'config' struct properly, then it calls the curl_easy_*() functions of the library and when it gets back control after the curl_easy_perform() it cleans up the library, checks status and exits. When the operation is done, the ourWriteOut() function in src/writeout.c may be called to report about the operation. That function is using the curl_easy_getinfo() function to extract useful information from the curl session. Recent versions may loop and do all this several times if many URLs were specified on the command line or config file.Memory Debugging================ The file lib/memdebug.c contains debug-versions of a few functions. Functions such as malloc, free, fopen, fclose, etc that somehow deal with resources that might give us problems if we "leak" them. The functions in the memdebug system do nothing fancy, they do their normal function and then log information about what they just did. The logged data can then be analyzed after a complete session, memanalyze.pl is the perl script present only present in CVS (not part of the release archives) that analyzes a log file generated by the memdebug system. It detects if resources are allocated but never freed and other kinds of errors related to resource management. Use -DMALLOCDEBUG when compiling to enable memory debugging, this is also switched on by running configure with --enable-debug.Test Suite========== Since November 2000, a test suite has evolved. It is placed in its own subdirectory directly off the root in the curl archive tree, and it contains a bunch of scripts and a lot of test case data. The main test script is runtests.pl that will invoke the two servers httpserver.pl and ftpserver.pl before all the test cases are performed. The test suite currently only runs on unix-like platforms. You'll find a complete description of the test case data files in the tests/README file. The test suite automatically detects if curl was built with the memory debugging enabled, and if it was it will detect memory leaks too.Building Releases================= There's no magic to this. When you consider everything stable enough to be released, run the 'maketgz' script (using 'make distcheck' will give you a pretty good view on the status of the current sources). maketgz prompts for version number of the client and the library before it creates a release archive. maketgz uses 'make dist' for the actual archive building, why you need to fill in the Makefile.am files properly for which files that should be included in the release archives.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -