Skip to content

ZendClient breaks when receiving an HTTP/2 response #19441

@ryanreeves-taxjar

Description

@ryanreeves-taxjar

Preconditions (*)

  1. Magento version 2.2.6
  2. a version of Curl that supports HTTP/2 (v 7.43.0 or above)
  3. (optional) CentOS operating system

Steps to reproduce (*)

  1. Make an api request using ZendClient and the Curl adapter to an API endpoint that returns an HTTP/2 response
  2. Receive the error "Invalid header line detected"

Expected result (*)

  1. The api response to be returned successfully without throwing an exception

Actual result (*)

  1. An exception is thrown because the HTTP/2 header format cannot be parsed.

Solution

  1. Alter the regex in Zend_Http_Response, function extractHeaders to properly validate HTTP/2
  2. Line 517: if ($index === 0 && preg_match('#^HTTP/\d+(?:\.\d+) [1-5]\d+#', $line)) {
    is where string "HTTP/2 200" breaks. The regex should optionally enforce the period since 2.0 was dropped from HTTP/2. Sample fixed regex: '#^HTTP/\d+(?:.\d+)? [1-5]\d+#'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions