-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Implemented FR #51634: Can't post multiple fields with the same name #8292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--TEST-- | ||
CURLOPT_POSTFIELDS with multi-value fields | ||
--EXTENSIONS-- | ||
sockets | ||
--FILE-- | ||
<?php | ||
$socket = stream_socket_server("tcp://0.0.0.0:29999", $errno, $errstr); | ||
cmb69 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (!$socket) { | ||
echo "$errstr ($errno)<br />\n"; | ||
return; | ||
} | ||
|
||
$url = "http://127.0.0.1:29999/get.inc?test=raw"; | ||
|
||
$fields = [ | ||
'single' => 'SingleValue', | ||
'multi' => [ | ||
'Multi1', | ||
'Multi2', | ||
] | ||
]; | ||
|
||
$options = array( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason not to use the short array syntax There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really, I probably copied it from the original example. Will fix. |
||
CURLOPT_POST => 1, | ||
CURLOPT_HEADER => 0, | ||
CURLOPT_URL => $url, | ||
CURLOPT_FRESH_CONNECT => 1, | ||
CURLOPT_RETURNTRANSFER => 1, | ||
CURLOPT_FORBID_REUSE => 1, | ||
CURLOPT_TIMEOUT => 1, | ||
CURLOPT_POSTFIELDS => $fields, | ||
); | ||
|
||
$ch = curl_init(); | ||
curl_setopt_array($ch, $options); | ||
|
||
$curl_content = curl_exec($ch); | ||
curl_close($ch); | ||
|
||
$conn = stream_socket_accept($socket); | ||
echo stream_get_contents($conn); | ||
?> | ||
--EXPECTF-- | ||
POST /get.inc?test=raw HTTP/1.1 | ||
Host: %s | ||
Accept: */* | ||
Content-Length: %d | ||
Content-Type: multipart/form-data; boundary=------------------------%s | ||
|
||
--------------------------%s | ||
Content-Disposition: form-data; name="single" | ||
|
||
SingleValue | ||
--------------------------%s | ||
Content-Disposition: form-data; name="multi" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @derickr Hi! Sorry to bother you. I am trying to do the same request with PHP 8.2.9, which doesn't work as expected. What I get is that names are overwritten. So, from this particular test, the receiver will only get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No,
|
||
|
||
Multi1 | ||
--------------------------%s | ||
Content-Disposition: form-data; name="multi" | ||
|
||
Multi2 | ||
--------------------------%s-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: An else-case and removing the
continue
could remove the duplicatezend_string_release_ex
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but IMO the current code is more readable, as each special block now looks the same. If we'd to add one in the future, then it's less likely the wrong thing gets copied. (I'm also allergic to
else
).