From 89c999da0b9c6383d9791eed491a0eac40da5a48 Mon Sep 17 00:00:00 2001 From: Eric Soderstrom Date: Wed, 3 Oct 2018 15:26:02 -0400 Subject: [PATCH] Correctly convert milliseconds to seconds. --- google/appengine/runtime/CurlLite.php | 2 +- google/appengine/runtime/CurlLiteTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/google/appengine/runtime/CurlLite.php b/google/appengine/runtime/CurlLite.php index d3929c63..4b72c458 100644 --- a/google/appengine/runtime/CurlLite.php +++ b/google/appengine/runtime/CurlLite.php @@ -418,7 +418,7 @@ private function setOption($key, $value) { $this->request->setDeadline($value); break; case CURLOPT_TIMEOUT_MS: - $this->request->setDeadline($value * 1000); + $this->request->setDeadline($value / 1000); break; case CURLOPT_CUSTOMREQUEST: if (!in_array($value, array_keys(static::$custom_request_map))) { diff --git a/google/appengine/runtime/CurlLiteTest.php b/google/appengine/runtime/CurlLiteTest.php index f5ac1fee..9caf6fa9 100644 --- a/google/appengine/runtime/CurlLiteTest.php +++ b/google/appengine/runtime/CurlLiteTest.php @@ -445,6 +445,24 @@ public function testGetInfo() { $this->apiProxyMock->verify(); } + public function testSetTimeoutMS() { + $url = 'http://google.com'; + $this->setupRequest($url); + $this->request->setDeadline(0.5); + $this->apiProxyMock->expectCall('urlfetch', + 'Fetch', + $this->request, + $this->response); + + $curl_lite = new CurlLite(); + $result = $curl_lite->setOptionsArray([ + CURLOPT_TIMEOUT_MS => 500, + CURLOPT_URL => $url + ]); + $curl_lite->exec(); + $this->assertEquals($result, true); + } + public function mockLog($log_level, $log_message) { $this->assertFalse(empty($this->expected_log_messages)); $expected = array_shift($this->expected_log_messages);