Skip to content

Test curl#4

Open
mt-omarov wants to merge 46 commits intomasterfrom
test_curl
Open

Test curl#4
mt-omarov wants to merge 46 commits intomasterfrom
test_curl

Conversation

@mt-omarov
Copy link
Owner

No description provided.

…setopt, expanded curl_getinfo by adding CURLINFO_CERTINFO logic
…AL, PATH_AS_IS, PIPEWAIT, SASL_IR, CONNECT_TO, PROXYHEADER
…FO_CERTINFO option. Added curl_setopt options: SSL_VERIFYSTATUS, NORPOGRESS, NOSIGNAL, PATH_AS_IS, PIPEWAIT, SASL_IR, CONNECT_TO, PROXYHEADER
…_HAPPY_EYEBALLS_TIMEOUT_MS, CURLOPT_HEADEROPT, CURLOPT_POSTREDIR. Defined flags for the logic of headeropt and postredir options
…PY_EYEBALLS_TIMEOUT_MS, CURLOPT_HEADEROPT, CURLOPT_POSTREDIR. Created new option_setter functions for the headeropt and postredir options.
… CURLOPT_DEFAULT_PROTOCOL, CURLOPT_DNS_INTERFACE. Added curl_version() function.
…OXY_SSL_CIPHER_LIST, CURLOPT_PROXY_TLS13_CIPHERS, CURLOPT_PROXY_SSLKEY, etc. Removed not supported CURLOPT_DNS_INTERFACE option.
…pes, replaced copying of streams with pointers. Completed support for callable options logic
@mt-omarov mt-omarov force-pushed the test_curl branch 2 times, most recently from d7e3b49 to 8fb8c0e Compare December 17, 2023 15:32
@mt-omarov mt-omarov force-pushed the test_curl branch 10 times, most recently from 2604384 to 6748cf9 Compare December 19, 2023 22:10
builtin-functions/_funcions.txt:
	Added an alias CURLOPT_WRITEDATA for the option CURLOPT_FILE.
runtime/curl.h:
	Fixed callable type names (<callable_type> -> on_<callable_type>), moved it to namespace.
runtime/curl.cpp:
	1. Brought to a general appearance all fields of callable objects of the Easy_Context class: struct {...} <callable_name>_handle.
	2. Added an additional null value check to the stream_option_setter function.
	3. Deleted the incorrect installation of the method of operation of the curl_read function when installing the CURLOPT_INFILE option.
	4. Replaced the curl error code CURLE_WRITE_ERROR with -1 for errors in the stream_option_setter function.
	5. Fixed a bug in the curl_read function: copying to a buffer variable is done via calls to $fgets() and memcpy().
Refactored class Process:
	1. Deleted unnecessary function run_cmd().
	2. Fixed the definition of the process id using the lsof call relative to the listening port.
	3. Added exception throwing and corrected syntax.
Added a test for the CURLOPT_WRITEHEADER option:
	1. It works by analogy with the test for CURLOPT_FILE.
	2. The response headers are written to the file, but kphp returns more information => only the beginning of the file is checked.
All tests now take 60 ms to start the server.
…RESSFUNCTION. Refactored tests for stream-options.

14_curl_setopt_streams.php:
	1. Moved common variables to the global scope.
	2. Increased delays for creating and closing the server: from 60 to 200 ms.
17_curl_setopt_callables.php:
	1. Option tests were created by analogy with stream tests.
	2. Port values for php and kphp differ from stream tests to avoid intersections.
	3. Testing the PROGRESSFUNCTION option uses the CURLOPT_FILE stream option and raises the server, which sends the locally created document to the client when the request is received.
…s in stream-tests. Rewrited the logic of curl_read function in runtime/curl.cpp.

curl_read() in runtime/curl.cpp:
	Previously, the result of calling a custom function was missed, now the returned string is written to memory via memcpy().
testing CURLOPT_READFUNCTION:
	1. The test is written by analogy with the test of the CURLOPT_INFILE option, which sends data to the server.
	2. At the moment, the user-defined function is required to return exactly the string.
In the runtime in curl.cpp the value of the f$fopen() function is passed as a descriptor, which returns Stream (an alias of a mixed type, which is just a string variable).
When calling curl_setopt() with options for stream descriptors, you need to check which mode they are open with. In the kphp runtime, this can only be checked if you have access to static variables from files.cpp .

To solve the problem of access to files.cpp, the get_file_mode() function was added, which gets a Stream variable, receives information on FILE* and returns the descriptor mode code.

To test get_file_mode(), the f$stream_test() function was also added to curl.cpp which can be called from php code.

The stream_option_setter() function was fixed using get_file_mode().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant