ZF-4526: Capitalization of headers breaks file uploads


When uploading files to a particular web application I'm working with using Zend_Http_Client, the web application does not see the files that I'm uploading using $zendHttpClient->setFileUpload(). However, if I change the Content-type header for the file part(s) to "Content-Type" (with a capital "T"), and the Content-disposition header to "Content-Disposition" (with a capital "D"), the file and its type is recognized. I've verified that the capitalization of both headers must be changed in order for the web application to recognize the files.

I realize that this is probably a bug in the web application I'm interfacing with, but unfortunately I don't have control over that application. According to my tests, at least IE 7 uses the Content-Type (capital "T") and Content-Disposition (capital "D") headers.

Changing the capitalization of these headers in Zend/Http/Client.php @ r11407 on lines 1012 and 1130 appears to fix this.


Change as following in SVN r11768

  1. Create 2 constants, CONTENT_TYPE and CONTENT_LENGTH. Use CONTENT_TYPE instead of 'Content-type' and CONTENT_LENGTH instead of 'Content-length'.
  2. Change from 'Content-disposition' to 'Content-Disposition' . Capitalization of 'D'.
  3. Change from 'User-agent' to 'User-Agent' . Capitalization of 'A'.

I don't mind the change but hell, all standards (namely the HTTP RFC) clearly states that headers case is to be ignored and that headers are case insensitive. It doesn't matter what IE sends, what matters is what the standards say, and I would personally leave it all lower case.

The bug is in the app you are working with, and they are likely to have problems with other clients.

That said, I don't mind the change - but what happens if someone comes along in a month saying the app they are working with expects other capitalization? do we change it again? Perhaps we should come up with a way to customize this (e.g. static properties that define these headers which can be overridden through inheritance).