Bug #66436 [Com]: CURLOPT_POSTFIELDS duplicate field names

From: Date: Wed, 08 Jan 2014 23:41:28 +0000
Subject: Bug #66436 [Com]: CURLOPT_POSTFIELDS duplicate field names
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183653@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66436&edit=1

 ID:                 66436
 Comment by:         cmbecker69 at gmx dot de
 Reported by:        julian at julianrhindconsulting dot com
 Summary:            CURLOPT_POSTFIELDS duplicate field names
 Status:             Open
 Type:               Bug
 Package:            cURL related
 Operating System:   any
 PHP Version:        5.5.7
 Block user comment: N
 Private report:     N

 New Comment:

duplicate of #51634


Previous Comments:
------------------------------------------------------------------------
[2014-01-07 16:50:44] julian at julianrhindconsulting dot com

Description:
------------
Hi

There appears to be a problem with the current curl implementation in regard to duplicate post
fields - especially when also wanting to post files

In order to call curl_setopt option CURLOPT_POSTFIELDS with the following data

name=Bob
name=Mary

this can be done using the string form passing

'name=Bob&name=Mary'

however it can't be done using the array form

['name'=>'Bob', 'name'=>'Mary']

for obvious reasons

When posting files it appears to be a requirement to use the array form

So what is one to do - if one wants to post duplicate field names and files?

This bug/design problem appears to be long standing and is inquired widely on the internet - however
no one appears to be trying to resolve it

Is it possible this could be resolved?

The simplest solution would appear to be to handle a field name pointing to an array as a duplicate
field name - so one would specify

[name=>['Bob','Mary']]

and curl_setopt would generate

name=Bob&name=Mary

I also note that this exact problem occurs when receiving posted data via $_POST - again the same
solution could be used - duplicate posted fields would return an array rather than a single value

I'm also aware of a workaround - using

['name[0]'=>'Bob','name[1]'=>'Mary']

however this does not generate the correct post data - but may be understood by the server if it
happens to be running PHP

Regards

Julian

Julian Rhind


Expected result:
----------------
name=Bob&name=Mary

Actual result:
--------------
name=Mary


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=66436&edit=1


Thread (4 messages)

« previous php.bugs (#183653) next »