8

Invalid response line returned from server: HTTP/2 200

I get the above error message when I want to log in to the extension manager.

Does anyone know how I can solve this?

Love to hear if someone has a solution for this.

1
  • Can you elaborate more on this. what error message you are facing Commented Nov 12, 2018 at 13:13

5 Answers 5

2

I got this answer from stackchange from Asim.

A solution that worked for me is to replace the following code at

lib/internal/Magento/Framework/HTTP/Client/Curl.php or vendor/magento/framework/HTTP/Client/Curl.php

Add Following changes in this function : protected function parseHeaders($ch, $data)

if ($this->_headerCount == 0) {
    $line = explode(" ", trim($data), 3);
    /* Remove this line */
    //if (count($line) != 3) {
/* Add this line */
if (count($line) < 2) {
  $this->doError("Invalid response line returned from server: " . $data);
}
$this->_responseStatus = intval($line[1]);
2

As alternative, you can update regexp in both places:

line 185: replace

if (! preg_match('|^\d\.\d$|', $version)) { with

if (! preg_match('|^\d(\.\d)?$|', $version)) {

line 517: replace

if ($index === 0 && preg_match('#^HTTP/\d+(?:\.\d+) [1-5]\d+#', $line)) { with

if ($index === 0 && preg_match('#^HTTP/\d+(?:\.\d+|) [1-5]\d+#', $line)) {

This should work for both HTTP/1.1 and HTTP/2 response headers

0

I had the same problem and the solution on this page https://community.magento.com/t5/Magento-2-x-Version-Upgrades/Sign-in-to-Magento-Marketplace-gt-quot-Invalid-response-line/td-p/111720 worked for me.

0

A solution that worked for me is to replace the following code at:

lib/internal/Magento/Framework/HTTP/Client/Curl.php or vendor/magento/framework/HTTP/Client/Curl.php

Add Following changes in this function :

protected function parseHeaders($ch, $data)

if ($this->_headerCount == 0) {
    $line = explode(" ", trim($data), 3);
    /* Remove this line */
    //if (count($line) != 3) {
    /* Add this line */
if (count($line) < 2) {
   $this->doError("Invalid response line returned from server: " . 
$data);
}
$this->_responseStatus = intval($line[1]);
-1

I face with same issue but with stripe module. I suggest you to go vendor/magento/zendframework1/library/Zend/Http/Response.php on line 517 and add

if ($index === 0 && preg_match('#^HTTP/2 200#', $line)) {
 // Status line; ignore
 continue;
}

and on line 184 comment

// Set the HTTP version
    // if (! preg_match('|^\d\.\d$|', $version)) {
    //     #require_once 'Zend/Http/Exception.php';
    //     throw new Zend_Http_Exception("Invalid HTTP response version: $version");
    // }

Note. It's a hot fix. I hope it help you.

3
  • Changing core files directly is highly discouraged. Commented Nov 13, 2018 at 5:31
  • How do you make this change outside of vendor? Commented Jul 15, 2019 at 14:21
  • Look here bitbucket.org/nosro/extend-zend1 (Note. write correct vendor name)
    – Orson
    Commented Jul 31, 2019 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.