magento / magento/upward-php

magento clound doesn't handle compressed resonse right

Open
#85 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
14
Forks
16
PR merge metrics
No merged PRs in 30d

Description

hi, I deployed app to magento cloud, I got a gzip content on the web page, once I set `Accept-encoding` below, it work as expected. should we uncompress response automatically ?

resolver/Proxy.php
```
public function resolve($definition)
{
if (!$definition instanceof Definition) {
throw new \InvalidArgumentException('$definition must be an instance of ' . Definition::class);
}

$target = $this->getIterator()->get('target', $definition);
$ignoreSSLErrors = $definition->has('ignoreSSLErrors')
? $this->getIterator()->get('ignoreSSLErrors', $definition)
: false;
$request = new \Zend\Http\PhpEnvironment\Request();
$originalRequestURI = clone $request->getUri();
$request->setUri($target);
$request->getUri()->setPath($originalRequestURI->getPath())->setQuery($originalRequestURI->getQuery());
$requestHeaders = $request->getHeaders();

// decompress automatically
$requestHeaders->removeHeader('Accept-encoding');
$requestHeaders->addHeaderLine('Accept-encoding', '');

if ($requestHeaders && $requestHeaders->has('Host')) {
$requestHeaders->removeHeader($request->getHeader('Host'));
$requestHeaders->addHeaderLine('Host', parse_url($target, PHP_URL_HOST));
}

$client = new Client(null, [
'adapter' => Client\Adapter\Curl::class,
'curloptions' => [
CURLOPT_SSL_VERIFYHOST => $ignoreSSLErrors ? 0 : 2,
CURLOPT_SSL_VERIFYPEER => !$ignoreSSLErrors,
],
]);

return $client->send($request);
}
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with resolver/Proxy.php and the resolve($definition) entry point, then inspect how the Zend HTTP client and cURL adapter handle compressed responses. Reproduce the Magento Cloud response described in the issue and verify that the returned response is usable without the manual Accept-encoding workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.