本文整理匯總了PHP中Google_Http_Request::disableGzip方法的典型用法代碼示例。如果您正苦於以下問題:PHP Google_Http_Request::disableGzip方法的具體用法?PHP Google_Http_Request::disableGzip怎麽用?PHP Google_Http_Request::disableGzip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Google_Http_Request
的用法示例。
在下文中一共展示了Google_Http_Request::disableGzip方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGzipSupport
public function testGzipSupport()
{
$url = 'http://localhost:8080/foo/bar?foo=a&foo=b&wowee=oh+my';
$request = new Google_Http_Request($url);
$request->enableGzip();
$this->assertStringEndsWith(Google_Http_Request::GZIP_UA, $request->getUserAgent());
$this->assertArrayHasKey('accept-encoding', $request->getRequestHeaders());
$this->assertTrue($request->canGzip());
$request->disableGzip();
$this->assertStringEndsNotWith(Google_Http_Request::GZIP_UA, $request->getUserAgent());
$this->assertArrayNotHasKey('accept-encoding', $request->getRequestHeaders());
$this->assertFalse($request->canGzip());
}
示例2: acquireAccessToken
/**
* Acquires a new access token from the compute engine metadata server.
* @throws Google_Auth_Exception
*/
public function acquireAccessToken()
{
$request = new Google_Http_Request(self::METADATA_AUTH_URL, 'GET', array('Metadata-Flavor' => 'Google'));
$request->disableGzip();
$response = $this->client->getIo()->makeRequest($request);
if ($response->getResponseHttpCode() == 200) {
$this->setAccessToken($response->getResponseBody());
$this->token['created'] = time();
return $this->getAccessToken();
} else {
throw new Google_Auth_Exception(sprintf("Error fetching service account access token, message: '%s'", $response->getResponseBody()), $response->getResponseHttpCode());
}
}
示例3: nextChunk
/**
* Send the next part of the file to upload.
* @param [$chunk] the next set of bytes to send. If false will used $data passed
* at construct time.
*/
public function nextChunk($chunk = false)
{
if (false == $this->resumeUri) {
$this->resumeUri = $this->getResumeUri();
}
if (false == $chunk) {
$chunk = substr($this->data, $this->progress, $this->chunkSize);
}
$lastBytePos = $this->progress + strlen($chunk) - 1;
$headers = array('content-range' => "bytes {$this->progress}-{$lastBytePos}/{$this->size}", 'content-type' => $this->request->getRequestHeader('content-type'), 'content-length' => $this->chunkSize, 'expect' => '');
$httpRequest = new Google_Http_Request($this->resumeUri, 'PUT', $headers, $chunk);
if ($this->client->getClassConfig("Google_Http_Request", "enable_gzip_for_uploads")) {
$httpRequest->enableGzip();
} else {
$httpRequest->disableGzip();
}
$response = $this->client->getIo()->makeRequest($httpRequest);
$response->setExpectedClass($this->request->getExpectedClass());
$code = $response->getResponseHttpCode();
$this->httpResultCode = $code;
if (308 == $code) {
// Track the amount uploaded.
$range = explode('-', $response->getResponseHeader('range'));
$this->progress = $range[1] + 1;
// Allow for changing upload URLs.
$location = $response->getResponseHeader('location');
if ($location) {
$this->resumeUri = $location;
}
// No problems, but upload not complete.
return false;
} else {
return Google_Http_REST::decodeHttpResponse($response);
}
}
示例4: revokeToken
/**
* Revoke an OAuth2 access token or refresh token. This method will revoke the current access
* token, if a token isn't provided.
* @throws Google_Auth_Exception
* @param string|null $token The token (access token or a refresh token) that should be revoked.
* @return boolean Returns True if the revocation was successful, otherwise False.
*/
public function revokeToken($token = null)
{
if (!$token) {
if (!$this->token) {
// Not initialized, no token to actually revoke
return false;
} elseif (array_key_exists('refresh_token', $this->token)) {
$token = $this->token['refresh_token'];
} else {
$token = $this->token['access_token'];
}
}
$request = new Google_Http_Request(self::OAUTH2_REVOKE_URI, 'POST', array(), "token={$token}");
$request->disableGzip();
$response = $this->client->getIo()->makeRequest($request);
$code = $response->getResponseHttpCode();
if ($code == 200) {
$this->token = null;
return true;
}
return false;
}
示例5: revokeToken
/**
* Revoke an OAuth2 access token or refresh token. This method will revoke the current access
* token, if a token isn't provided.
* @throws Google_Auth_Exception
* @param string|null $token The token (access token or a refresh token) that should be revoked.
* @return boolean Returns True if the revocation was successful, otherwise False.
*/
public function revokeToken($token = null)
{
if (!$token) {
$token = $this->token['access_token'];
}
$request = new Google_Http_Request(self::OAUTH2_REVOKE_URI, 'POST', array(), "token={$token}");
$request->disableGzip();
$response = $this->client->getIo()->makeRequest($request);
$code = $response->getResponseHttpCode();
if ($code == 200) {
$this->token = null;
return true;
}
return false;
}
示例6: makePutRequest
/**
* Sends a PUT-Request to google drive and parses the response,
* setting the appropiate variables from the response()
*
* @param Google_Http_Request $httpRequest the Reuqest which will be send
*
* @return false|mixed false when the upload is unfinished or the decoded http response
*
*/
private function makePutRequest(Google_Http_Request $httpRequest)
{
if ($this->client->getClassConfig("Google_Http_Request", "enable_gzip_for_uploads")) {
$httpRequest->enableGzip();
} else {
$httpRequest->disableGzip();
}
$response = $this->client->getIo()->makeRequest($httpRequest);
$response->setExpectedClass($this->request->getExpectedClass());
$code = $response->getResponseHttpCode();
$this->httpResultCode = $code;
if (308 == $code) {
// Track the amount uploaded.
$range = explode('-', $response->getResponseHeader('range'));
$this->progress = $range[1] + 1;
// Allow for changing upload URLs.
$location = $response->getResponseHeader('location');
if ($location) {
$this->resumeUri = $location;
}
// No problems, but upload not complete.
return false;
} else {
return Google_Http_REST::decodeHttpResponse($response, $this->client);
}
}