-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addition of gzip feature #568
base: v3
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this pull request, good job.
Let's make sure we address my feedback before merging.
src/Config/SearchConfig.php
Outdated
@@ -29,6 +29,7 @@ public function getDefaultConfig() | |||
'defaultHeaders' => array(), | |||
'defaultForwardToReplicas' => null, | |||
'batchSize' => 1000, | |||
'gzipEnabled' => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point, @chloelbn you may need to refactor the pull request in order to prepare the PHP client for other compression types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't hesitate on syncing with me for tackling this refactorization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in the last commit, what are your thoughts?
src/Http/Psr7/Request.php
Outdated
@@ -62,6 +62,10 @@ public function __construct( | |||
$this->updateHostFromUri(); | |||
} | |||
|
|||
if ($this->hasHeader('Content-Encoding')) { | |||
$body = gzencode($body, 9); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's double check the level here, we are not sure if 9
is the correct level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's unit test this to make sure we have this header in both requests, maybe is already the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests added, as for compression 9 is the higher level but I guess it will take more time. Not sure how to benchmark which level to use
src/RetryStrategy/ApiWrapper.php
Outdated
@@ -111,6 +111,10 @@ public function send($method, $path, $requestOptions = array(), $hosts = null) | |||
|
|||
private function request($method, $path, RequestOptions $requestOptions, $hosts, $timeout, $data = array()) | |||
{ | |||
if ($this->canEnableGzipCompress($method)) { | |||
$requestOptions->addHeader('Content-Encoding', 'gzip'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the underlying HTTP library computing the content-length
header as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chloelbn Seems like tests are still failing, is the underlying http library setting this header?
"Content-Type: application/json; charset=utf-8"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, the gzip
feature might not be enable on the test servers we are targeting with the PHP library. Are they the same at the CTS one @nunomaduro? I couldn't check on travis as they are ciphered.
@chloelbn Let me know when I can review this 👍 |
@chloelbn I will check why travis is not passing the tests. |
|
Describe your change
What problem is this fixing?