Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

"Content-Length" header set to "0" returns header line without value #26

@curzio-della-santa

Description

@curzio-della-santa

Hi

Setting the "Content-Length" header to 0, will return an empty header line Content-Length: in the response.
This might break CORS preflight requests processed by load-balancers (e.g. on fortrabbit).

Problem is located in the \Zend\Http\Header\ContentLength constructor, that does not sets the $value property if 0 is passed.

Issue can be fixed in \Zend\Http\Header\ContentLength either:

  • changing the constructor behavior (accepting 0 or '0' as value):
    from if ($value) { to if ($value !== null) {
    Note: all other classes in the Zend\Http\Header namespace have the same similar (buggy?) constructor (except GenericHeader).

  • changing the getFieldValue method to:

      public function getFieldValue()
      {
          return $this->value ?: 0;
      }

As soon as fixed I recommend to change the requirement of "zfr/zfr-cors" to the newest version of "zendframework/zend-http"

Kind regards,
Curzio

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions