With multiple request only the first works
Closed this issue · 3 comments
mikgry commented
Hey,
Please look at the below example:
<?php
require('vendor/autoload.php');
use Sheetsu\Sheetsu;
$sheetsu = new Sheetsu([
'sheetId' => '020b2c0f'
]);
echo var_dump($sheetsu->read(2, 0));
echo var_dump($sheetsu->read(1, 0));
?>
It seems that the $sheetsu or $response objects are not cleared before next request. I've got the result below:
object(Sheetsu\Response)#5 (2) {
["http":"Sheetsu\Response":private]=>
object(Curl\Curl)#4 (16) {
["_cookies":"Curl\Curl":private]=>
array(0) {
}
["_headers":"Curl\Curl":private]=>
array(0) {
}
["curl"]=>
resource(12) of type (curl)
["error"]=>
bool(false)
["error_code"]=>
int(0)
["error_message"]=>
string(0) ""
["curl_error"]=>
bool(false)
["curl_error_code"]=>
int(0)
["curl_error_message"]=>
string(0) ""
["http_error"]=>
bool(false)
["http_status_code"]=>
int(200)
["http_error_message"]=>
string(0) ""
["request_headers"]=>
array(4) {
[0]=>
string(41) "GET /apis/v1.0/020b2c0f/?limit=2 HTTP/1.1"
[1]=>
string(17) "Host: sheetsu.com"
[2]=>
string(59) "User-Agent: PHP Curl/1.6 (+https://github.com/php-mod/curl)"
[3]=>
string(11) "Accept: */*"
}
["response_headers"]=>
array(12) {
[0]=>
string(15) "HTTP/1.1 200 OK"
[1]=>
string(13) "Server: nginx"
[2]=>
string(35) "Date: Mon, 13 Nov 2017 10:12:35 GMT"
[3]=>
string(44) "Content-Type: application/json;charset=UTF-8"
[4]=>
string(18) "Content-Length: 78"
[5]=>
string(22) "Connection: keep-alive"
[6]=>
string(42) "ETag: W/"72bb46c5a9e8a588e4139f3896569cfd""
[7]=>
string(50) "Cache-Control: max-age=0, private, must-revalidate"
[8]=>
string(50) "X-Request-Id: 27590baf-937f-4cc7-ba1e-8c6c07ed46df"
[9]=>
string(19) "X-Runtime: 1.011954"
[10]=>
string(12) "Vary: Origin"
[11]=>
string(43) "Strict-Transport-Security: max-age=15768000"
}
["response"]=>
string(78) "[{"id":"1","name":"Peter","score":"42"},{"id":"2","name":"Lois","score":"89"}]"
["response_header_continue":protected]=>
bool(false)
}
["errorHandler":"Sheetsu\Response":private]=>
NULL
}
object(Sheetsu\Response)#5 (2) {
["http":"Sheetsu\Response":private]=>
object(Curl\Curl)#4 (16) {
["_cookies":"Curl\Curl":private]=>
array(0) {
}
["_headers":"Curl\Curl":private]=>
array(0) {
}
["curl"]=>
resource(12) of type (curl)
["error"]=>
bool(false)
["error_code"]=>
int(0)
["error_message"]=>
string(0) ""
["curl_error"]=>
bool(false)
["curl_error_code"]=>
int(0)
["curl_error_message"]=>
string(0) ""
["http_error"]=>
bool(false)
["http_status_code"]=>
int(200)
["http_error_message"]=>
string(0) ""
["request_headers"]=>
array(4) {
[0]=>
string(50) "GET /apis/v1.0/020b2c0f/?limit=2/?limit=1 HTTP/1.1"
[1]=>
string(17) "Host: sheetsu.com"
[2]=>
string(59) "User-Agent: PHP Curl/1.6 (+https://github.com/php-mod/curl)"
[3]=>
string(11) "Accept: */*"
}
["response_headers"]=>
array(12) {
[0]=>
string(15) "HTTP/1.1 200 OK"
[1]=>
string(13) "Server: nginx"
[2]=>
string(35) "Date: Mon, 13 Nov 2017 10:12:37 GMT"
[3]=>
string(44) "Content-Type: application/json;charset=UTF-8"
[4]=>
string(18) "Content-Length: 78"
[5]=>
string(22) "Connection: keep-alive"
[6]=>
string(42) "ETag: W/"72bb46c5a9e8a588e4139f3896569cfd""
[7]=>
string(50) "Cache-Control: max-age=0, private, must-revalidate"
[8]=>
string(50) "X-Request-Id: 6ab1a16c-a7b9-41b9-b765-a7d474b9f2fe"
[9]=>
string(19) "X-Runtime: 1.093165"
[10]=>
string(12) "Vary: Origin"
[11]=>
string(43) "Strict-Transport-Security: max-age=15768000"
}
["response"]=>
string(78) "[{"id":"1","name":"Peter","score":"42"},{"id":"2","name":"Lois","score":"89"}]"
["response_header_continue":protected]=>
bool(false)
}
["errorHandler":"Sheetsu\Response":private]=>
NULL
}
As you can see the second request GET /apis/v1.0/020b2c0f/?limit=2/?limit=1 HTTP/1.1
keeps parameters of the first request and the response of the second request is equal to the first one, but it should be diffrent. I think the params should be cleared before next request.
emilianozublena commented
As far as i can see in the code, you are correct. I'll try to push the fix ASAP
emilianozublena commented
Fixed, issue was in the setting of configs in Sheetsu main object, array_merge was replaced for a foreach that replaces only the new values given by array $config
mikgry commented
Thanks a lot 😄