Commit graph

644 commits

Author SHA1 Message Date
David Carlier
10921525e6
Add CURLOPT_MAXFILESIZE_LARGE option
Like other *LARGE options, it takes a 64 bit value.

Closes GH-8557.
2022-05-16 11:01:28 +02:00
Derick Rethans
fb3cba494e Fix multi-same-name-fields in Curl for old (> 7.56.0) versions 2022-04-29 16:39:01 +01:00
David Carlier
7a45dcfe2e
Introduce CURLOPT_XFERINFOFUNCTION
`CURLOPT_XFERINFOFUNCTION` is available as of cURL 7.32.0, and
supersedes `CURLOPT_PROGRESSFUNCTION` which is still supported by
latest cURL, though.

Closes GH-7823.
2022-04-22 18:09:06 +02:00
Derick Rethans
8093ed6168 Implemented FR #51634: Can't post multiple fields with the same name
This PR allows for multiple values with the same field name to be sent to an
HTTP server. This server can't be PHP, because PHP's POST processing does not
allow for two the same field names. But sending multiple fields with the same
name is required for some operations by RFC 7578.

This PR allows you to attach an array of values to a field name, and each of
these will then be sent as its own distinct multipart/form-data field.
2022-04-07 10:01:31 +01:00
Ayesh Karunaratne
d23e36da81 Add CURLINFO_EFFECTIVE_METHOD
Since Curl 7.72.0, it supports a new parameter
called `CURLINFO_EFFECTIVE_METHOD`, which returns the effect method
in HTTP(s) requests. This is similar to `CURLINFO_EFFECTIVE_URL`.

 - https://curl.se/libcurl/c/CURLINFO_EFFECTIVE_METHOD.html

This adds support for CURLINFO_EFFECTIVE_URL if ext/curl is built
with libcurl >= 7.72.0 (0x074800).

Closes GH-7595.
2021-10-21 10:33:40 +02:00
George Peter Banyard
5ad1b89789 Use more specific types instead of int in cURL extension 2021-09-30 14:34:39 +01:00
Nikita Popov
5adfcfe746 Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid dangling pointer in curl header.str
2021-08-31 17:25:38 +02:00
Nikita Popov
db055fdb89 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Avoid dangling pointer in curl header.str
2021-08-31 17:24:30 +02:00
Alexey Zamorov
8c292a2f9d Avoid dangling pointer in curl header.str
If buf_len is zero, this would leave behind a dangling pointer
to an already released header.str. Make sure this can't happen
by always overwriting the pointer.

Closes GH-7376.
2021-08-31 17:23:58 +02:00
Nikita Popov
4ba7e5b24d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix curl_copy_handle() with CURLINFO_HEADER_OUT
2021-08-31 17:09:34 +02:00
Nikita Popov
416dd524f9 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix curl_copy_handle() with CURLINFO_HEADER_OUT
2021-08-31 17:09:07 +02:00
Nikita Popov
30e791ed56 Fix curl_copy_handle() with CURLINFO_HEADER_OUT
The CURLOPT_DEBUGDATA will point to the old curl handle after
copying. Update it to point to the new handle.

We don't separately store whether CURLINFO_HEADER_OUT is enabled,
so I'm doing this unconditionally. It should be harmless if
CURLOPT_DEBUGFUNCTION is not used.
2021-08-31 17:06:41 +02:00
Joe Watkins
570d9b63e9
Not serializable flag permeation 2021-07-20 12:28:35 +02:00
Cameron Porter
b11785c5e4 Fixed bug #81085: Add version 7.71.0 blob options.
Adds support for the following options beginning with version 7.71.0:

    CURLOPT_ISSUERCERT_BLOB
    CURLOPT_PROXY_ISSUERCERT
    CURLOPT_PROXY_ISSUERCERT_BLOB
    CURLOPT_PROXY_SSLCERT_BLOB
    CURLOPT_PROXY_SSLKEY_BLOB
    CURLOPT_SSLCERT_BLOB
    CURLOPT_SSLKEY_BLOB

Closes GH-7194.
2021-06-28 09:54:45 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Nikita Popov
ce0bc58c22 Merge branch 'PHP-8.0'
* PHP-8.0:
  Mark resource-like objects as non-comparable
2021-02-16 14:22:03 +01:00
Nikita Popov
b63ea1047a Mark resource-like objects as non-comparable
As these hold on to some internal resource, there can't be two
"equal" objects with different identity. Make sure the lack of
public properties doesn't result in these being treated as always
equal.
2021-02-16 14:20:45 +01:00
Alexander Moskalev
e727919b97 cURL: make possible to send file from buffer string
Add CURLStringFile class which works similarly to CURLFile, but
uploads a file from a string rather than a file. This avoids the
need to create a temporary file, or use of a data:// stream.

Basic usage:

    $file = new CURLStringFile($data, 'filename.txt', 'text/plain');
    curl_setopt($curl, CURLOPT_POSTFIELDS, ['file' => $file]);

Closes GH-6456.
2021-02-16 10:24:22 +01:00
Máté Kocsis
5f21062054
Generate class entries for a few extensions
Relates to GH-6644
2021-02-03 09:24:09 +01:00
Nikita Popov
8c00c919e3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing derefs in CurlFile
2021-02-02 10:32:25 +01:00
Nikita Popov
0ec7bfaa43 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Add missing derefs in CurlFile
2021-02-02 10:32:11 +01:00
Nikita Popov
54fa0a69f8 Add missing derefs in CurlFile
As pointed out on GH-6456.
2021-02-02 10:31:16 +01:00
Christoph M. Becker
d0e3fb495f Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80595: Resetting POSTFIELDS to empty array breaks request
2021-01-18 11:01:39 +01:00
Christoph M. Becker
c321896a37 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80595: Resetting POSTFIELDS to empty array breaks request
2021-01-18 11:01:01 +01:00
Christoph M. Becker
38ad37ad43 Fix #80595: Resetting POSTFIELDS to empty array breaks request
This is mainly to work around https://github.com/curl/curl/issues/6455,
but not building the mime structure for empty hashtables is a general
performance optimization, so we do not restrict it to affected cURL
versions (7.56.0 to 7.75.0).

The minor change to bug79033.phpt is unexpected, but should not matter
in practice.

Closes GH-6606.
2021-01-18 10:57:56 +01:00
Ayesh Karunaratne
3dad63b5b2 Curl: Add CURLOPT_DOH_URL option
From libcurl version 7.62.0 and later, it supports DNS-over-HTTPS with
[`CURLOPT_DOH_URL`](https://curl.se/libcurl/c/CURLOPT_DOH_URL.html) option.
This adds integration with the `CURLOPT_DOH_URL` option if libcurl version
is >= 7.62.0 (0x073E00).

For reference, Ubuntu 20.04+ `libcurl4-openssl-dev`-based PHP builds use Curl 7.68.

Closes GH-6612.
2021-01-18 10:00:31 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
5276ca6179 Manually store CURLOPT_PRIVATE data
This is simpler than going through curl, because we can manage
the memory more easily (in particular, this removes the need for
to_free->str). Additionally this allows the CURLOPT_PRIVATE data
to have any type, instead of being implicitly cast to string.
2021-01-04 16:59:57 +01:00
Nikita Popov
5c21d39d55 Remove method member from php_curl_callback
For these callbacks a non-null callback already indicates that
a user callback should be used. We don't need an additional
member to tell us the same thing.
2021-01-04 16:24:20 +01:00
Nikita Popov
ce2e1076d4 Don't allocate php_curl_handlers separately
Always allocated together with php_curl... no point in that.
2021-01-04 15:59:18 +01:00
Nikita Popov
66ffa1c9d2 Use single typedef for curl callbacks
There's no value in making these separate types.
2021-01-04 15:19:01 +01:00
Nikita Popov
b4a2a9662b Retain reference to share handle from curl handle
Not keeping a reference will not result in use after free, because
curl protects against it, but it will result in a memory leak,
because curl_share_cleanup() will fail. We should make sure that
the share handle object stays alive as long as the curl handles
use it.
2020-11-11 11:56:03 +01:00
Nikita Popov
d96219c185 Fixed bug #80121
The issue affected both CurlHandle and CurlMultiHandle. I'll have
to double check this for other resource->object conversions as well.
2020-10-01 17:05:23 +02:00
Nikita Popov
7e339a335e Make null byte error a ValueError
Currently we treat paths with null bytes as a TypeError, which is
incorrect, and rather inconsistent, as we treat empty paths as
ValueError. We do this because the error is generated by zpp and
it's easier to always throw TypeError there.

This changes the zpp implementation to throw a TypeError only if
the type is actually wrong and throw ValueError for null bytes.
The error message is also split accordingly, to be more precise.

Closes GH-6094.
2020-09-08 15:23:23 +02:00
Nikita Popov
85b5dc4711 Private/public split curl header
To allow exporting the php_curl.h header containing curl class
entries, split off a separate curl_private.h header with all the
implementation details.

We may move or expose additional APIs in php_curl.h on an as-needed
basis.
2020-09-07 11:12:41 +02:00
Nikita Popov
d1ac7e3ab1 Remove some unnecessary HAVE_EXTNAME guards
A recurring pattern in old extension: Putting the whole source
code behind HAVE_EXTNAME. This is pointless, as the code is only
compiled if the extension is enabled.

This removes a couple of them, but not all.
2020-09-07 11:05:07 +02:00
Máté Kocsis
517c9938af
Promote warnings to exceptions in ext/curl
Closes GH-5963
2020-08-14 17:40:35 +02:00
Nikita Popov
7991fc2753 Accept zend_object in zend_read_property 2020-08-07 16:40:27 +02:00
Nikita Popov
d92229d8c7 Implement named parameters
From an engine perspective, named parameters mainly add three
concepts:

 * The SEND_* opcodes now accept a CONST op2, which is the
   argument name. For now, it is looked up by linear scan and
   runtime cached.
 * This may leave UNDEF arguments on the stack. To avoid having
   to deal with them in other places, a CHECK_UNDEF_ARGS opcode
   is used to either replace them with defaults, or error.
 * For variadic functions, EX(extra_named_params) are collected
   and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS.

RFC: https://wiki.php.net/rfc/named_params

Closes GH-5357.
2020-07-31 15:53:36 +02:00
Nikita Popov
302933daea Remove no_separation flag 2020-07-07 09:30:24 +02:00
Nikita Popov
632766a561 Disallow separation in a number of callbacks
All of these clearly do not need separation support.
2020-07-07 09:02:24 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Nikita Popov
6e1990dea6 Don't accept objects instead of arrays in curl
This properly addresses the issue from bug #79741. Silently
interpreting objects as mangled property tables is almost
always a bad idea.

Closes GH-5773.
2020-06-29 15:56:22 +02:00
Nikita Popov
f930978b70 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79741
2020-06-26 12:29:43 +02:00
Nikita Popov
978cdb736a Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79741
2020-06-26 12:29:23 +02:00
Nikita Popov
43cd3f6814 Fixed bug #79741 2020-06-26 12:28:39 +02:00
Nikita Popov
653e4ea1c5 Add flag to forbid dynamic property creation on internal classes
While performing resource -> object migrations, we're adding
defensive classes that are final, non-serializable and non-clonable
(unless they are, of course). This path adds a ZEND_ACC_NO_DYNAMIC_PROPERTIES
flag, that also forbids the creation of dynamic properties on these objects.
This is a subset of #3931 and targeted at internal usage only
(though may be extended to userland at some point in the future).

It's already possible to achieve this (what the removed
WeakRef/WeakMap code does), but there's some caveats: First, this
simple approach is only possible if the class has no declared
properties, otherwise it's necessary to special-case those
properties. Second, it's easy to make it overly strict, e.g. by
forbidding isset($obj->prop) as well. And finally, it requires a
lot of boilerplate code for each class.

Closes GH-5572.
2020-06-24 11:52:36 +02:00
Nikita Popov
26171c3690 Also allow casting CurlMultiHandles 2020-06-22 15:09:22 +02:00
Nikita Popov
1c4463c77a Allow casting CurlHandle to int
(int) $curlHandle will return spl_object_id($curlHandle). This
makes curl handle objects backwards compatible with code using
(int) $curlHandle to obtain a resource ID.

Closes GH-5743.
2020-06-19 23:05:47 +02:00