当前位置: 首页>>代码示例>>PHP>>正文


PHP RequestCore::set_seek_position方法代码示例

本文整理汇总了PHP中RequestCore::set_seek_position方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestCore::set_seek_position方法的具体用法?PHP RequestCore::set_seek_position怎么用?PHP RequestCore::set_seek_position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RequestCore的用法示例。


在下文中一共展示了RequestCore::set_seek_position方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: auth


//.........这里部分代码省略.........
     $request->set_useragent($user_agent);
     // Streaming uploads
     if (isset($options[self::OSS_FILE_UPLOAD])) {
         if (is_resource($options[self::OSS_FILE_UPLOAD])) {
             $length = null;
             if (isset($options[self::OSS_CONTENT_LENGTH])) {
                 $length = $options[self::OSS_CONTENT_LENGTH];
             } elseif (isset($options[self::OSS_SEEK_TO])) {
                 $stats = fstat($options[self::OSS_FILE_UPLOAD]);
                 if ($stats && $stats[self::OSS_SIZE] >= 0) {
                     $length = $stats[self::OSS_SIZE] - (int) $options[self::OSS_SEEK_TO];
                 }
             }
             $request->set_read_stream($options[self::OSS_FILE_UPLOAD], $length);
             if ($headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
                 $headers[self::OSS_CONTENT_TYPE] = 'application/octet-stream';
             }
         } else {
             $request->set_read_file($options[self::OSS_FILE_UPLOAD]);
             $length = $request->read_stream_size;
             if (isset($options[self::OSS_CONTENT_LENGTH])) {
                 $length = $options[self::OSS_CONTENT_LENGTH];
             } elseif (isset($options[self::OSS_SEEK_TO]) && isset($length)) {
                 $length -= (int) $options[self::OSS_SEEK_TO];
             }
             $request->set_read_stream_size($length);
             if (isset($headers[self::OSS_CONTENT_TYPE]) && $headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
                 $mime_type = self::get_mime_type($options[self::OSS_FILE_UPLOAD]);
                 $headers[self::OSS_CONTENT_TYPE] = $mime_type;
             }
         }
     }
     if (isset($options[self::OSS_SEEK_TO])) {
         $request->set_seek_position((int) $options[self::OSS_SEEK_TO]);
     }
     if (isset($options[self::OSS_FILE_DOWNLOAD])) {
         if (is_resource($options[self::OSS_FILE_DOWNLOAD])) {
             $request->set_write_stream($options[self::OSS_FILE_DOWNLOAD]);
         } else {
             $request->set_write_file($options[self::OSS_FILE_DOWNLOAD]);
         }
     }
     if (isset($options[self::OSS_METHOD])) {
         $request->set_method($options[self::OSS_METHOD]);
         $string_to_sign .= $options[self::OSS_METHOD] . "\n";
     }
     if (isset($options[self::OSS_CONTENT])) {
         $request->set_body($options[self::OSS_CONTENT]);
         if ($headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
             $headers[self::OSS_CONTENT_TYPE] = 'application/octet-stream';
         }
         $headers[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]);
         $headers[self::OSS_CONTENT_MD5] = base64_encode(md5($options[self::OSS_CONTENT], true));
     }
     uksort($headers, 'strnatcasecmp');
     foreach ($headers as $header_key => $header_value) {
         $header_value = str_replace(array("\r", "\n"), '', $header_value);
         if ($header_value !== '') {
             $request->add_header($header_key, $header_value);
         }
         if (strtolower($header_key) === 'content-md5' || strtolower($header_key) === 'content-type' || strtolower($header_key) === 'date' || isset($options['self::OSS_PREAUTH']) && (int) $options['self::OSS_PREAUTH'] > 0) {
             $string_to_sign .= $header_value . "\n";
         } elseif (substr(strtolower($header_key), 0, 6) === self::OSS_DEFAULT_PREFIX) {
             $string_to_sign .= strtolower($header_key) . ':' . $header_value . "\n";
         }
     }
开发者ID:codingoneapp,项目名称:codingone,代码行数:67,代码来源:sdk.class.php

示例2: auth


//.........这里部分代码省略.........
         if (is_resource($options[self::OSS_FILE_UPLOAD])) {
             $length = null;
             if (isset($options[self::OSS_CONTENT_LENGTH])) {
                 $length = $options[self::OSS_CONTENT_LENGTH];
             } elseif (isset($options[self::OSS_SEEK_TO])) {
                 $stats = fstat($options[self::OSS_FILE_UPLOAD]);
                 if ($stats && $stats[self::OSS_SIZE] >= 0) {
                     $length = $stats[self::OSS_SIZE] - (int) $options[self::OSS_SEEK_TO];
                 }
             }
             $request->set_read_stream($options[self::OSS_FILE_UPLOAD], $length);
             if ($headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
                 $headers[self::OSS_CONTENT_TYPE] = 'application/octet-stream';
             }
         } else {
             $request->set_read_file($options[self::OSS_FILE_UPLOAD]);
             $length = $request->read_stream_size;
             if (isset($options[self::OSS_CONTENT_LENGTH])) {
                 $length = $options[self::OSS_CONTENT_LENGTH];
             } elseif (isset($options[self::OSS_SEEK_TO]) && isset($length)) {
                 $length -= (int) $options[self::OSS_SEEK_TO];
             }
             $request->set_read_stream_size($length);
             if (isset($headers[self::OSS_CONTENT_TYPE]) && $headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
                 $extension = explode('.', $options[self::OSS_FILE_UPLOAD]);
                 $ext = array_pop($extension);
                 $mime_type = MimeTypes::get_mimetype($ext);
                 $headers[self::OSS_CONTENT_TYPE] = $mime_type;
             }
         }
         $options[self::OSS_CONTENT_MD5] = '';
     }
     if (isset($options[self::OSS_SEEK_TO])) {
         $request->set_seek_position((int) $options[self::OSS_SEEK_TO]);
     }
     if (isset($options[self::OSS_FILE_DOWNLOAD])) {
         if (is_resource($options[self::OSS_FILE_DOWNLOAD])) {
             $request->set_write_stream($options[self::OSS_FILE_DOWNLOAD]);
         } else {
             $request->set_write_file($options[self::OSS_FILE_DOWNLOAD]);
         }
     }
     if (isset($options[self::OSS_METHOD])) {
         $request->set_method($options[self::OSS_METHOD]);
         $string_to_sign .= $options[self::OSS_METHOD] . "\n";
     }
     if (isset($options[self::OSS_CONTENT])) {
         $request->set_body($options[self::OSS_CONTENT]);
         if ($headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
             $headers[self::OSS_CONTENT_TYPE] = 'application/octet-stream';
         }
         $headers[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]);
         $headers[self::OSS_CONTENT_MD5] = $this->hex_to_base64(md5($options[self::OSS_CONTENT]));
     }
     uksort($headers, 'strnatcasecmp');
     foreach ($headers as $header_key => $header_value) {
         $header_value = str_replace(array("\r", "\n"), '', $header_value);
         if ($header_value !== '') {
             $request->add_header($header_key, $header_value);
         }
         if (strtolower($header_key) === 'content-md5' || strtolower($header_key) === 'content-type' || strtolower($header_key) === 'date' || isset($options['self::OSS_PREAUTH']) && (int) $options['self::OSS_PREAUTH'] > 0) {
             $string_to_sign .= $header_value . "\n";
         } elseif (substr(strtolower($header_key), 0, 6) === self::OSS_DEFAULT_PREFIX) {
             $string_to_sign .= strtolower($header_key) . ':' . $header_value . "\n";
         }
     }
开发者ID:ijustyce,项目名称:zblogphp,代码行数:67,代码来源:sdk.class.php

示例3: invoke


//.........这里部分代码省略.........
                 $index = explode("->", $position);
                 $curIndexArg = $args;
                 $add = TRUE;
                 $curkey = "";
                 foreach ($index as $key1 => $value1) {
                     if (!isset($curIndexArg[$value1])) {
                         $add = FALSE;
                     } else {
                         $curIndexArg = $curIndexArg[$value1];
                         $curkey = $value1;
                     }
                 }
                 if (!empty($curIndexArg) && $add) {
                     $request->body = $curIndexArg;
                 }
             }
         }
     }
     //add ext headers
     //TODO
     //sign request
     $signer = NULL;
     if (isset($api["signer"])) {
         $signers = explode("->", $api["signer"]);
         foreach ($signers as $key => $value) {
             $signer = new $value();
             $log = $signer->sign($request, array("accessKey" => $this->accessKey, "secretKey" => $this->secretKey, "args" => $args));
             if (!empty($log)) {
                 $holder->msg .= $log . "\r\n";
             }
         }
     }
     if ($signer === NULL || !$signer instanceof QueryAuthSigner) {
         $url = $request->toUrl($this->endpoint);
         if ($location != NULL) {
             $url = $location;
         }
         $httpRequest = new RequestCore($url);
         if (KS3_API_DEBUG_MODE === TRUE) {
             $httpRequest->debug_mode = TRUE;
         }
         $httpRequest->set_method($request->method);
         foreach ($request->headers as $key => $value) {
             $httpRequest->add_header($key, $value);
         }
         $httpRequest->request_body = $request->body;
         if (isset($args["writeCallBack"])) {
             $httpRequest->register_streaming_write_callback($args["writeCallBack"]);
         }
         if (isset($args["readCallBack"])) {
             $httpRequest->register_streaming_read_callback($args["readCallBack"]);
         }
         $read_stream = $request->read_stream;
         $read_length = $request->getHeader(Headers::$ContentLength);
         $seek_position = $request->seek_position;
         if (isset($read_stream)) {
             $httpRequest->set_read_stream($read_stream, $read_length);
             $httpRequest->set_seek_position($seek_position);
             $httpRequest->remove_header(Headers::$ContentLength);
         }
         $write_stream = $request->write_stream;
         if (isset($write_stream)) {
             $httpRequest->set_write_stream($write_stream);
         }
         $holder->msg .= "request url->" . serialize($httpRequest->request_url) . "\r\n";
         $holder->msg .= "request headers->" . serialize($httpRequest->request_headers) . "\r\n";
         $holder->msg .= "request body->" . $httpRequest->request_body . "\r\n";
         $holder->msg .= "request read stream length->" . $read_length . "\r\n";
         $holder->msg .= "request read stream seek position->" . $seek_position . "\r\n";
         $httpRequest->send_request();
         //print_r($httpRequest);
         $body = $httpRequest->get_response_body();
         $data = new ResponseCore($httpRequest->get_response_header(), Utils::replaceNS2($body), $httpRequest->get_response_code());
         if ($data->status == 307) {
             $respHeaders = $httpRequest->get_response_header();
             $location = $respHeaders["location"];
             if (substr($location, 0, 4) == "http") {
                 $holder->msg .= "response code->" . $httpRequest->get_response_code() . "\r\n";
                 $holder->msg .= "response headers->" . serialize($httpRequest->get_response_header()) . "\r\n";
                 $holder->msg .= "response body->" . $body . "\r\n";
                 $holder->msg .= "retry request to " . $location . "\r\n";
                 //array($args)详见invoke开头
                 return $this->invoke($method, array($args), $holder, $location);
             }
         }
         $holder->msg .= "response code->" . $httpRequest->get_response_code() . "\r\n";
         $holder->msg .= "response headers->" . serialize($httpRequest->get_response_header()) . "\r\n";
         $holder->msg .= "response body->" . $body . "\r\n";
         $handlers = explode("->", $api["handler"]);
         foreach ($handlers as $key => $value) {
             $handler = new $value();
             $data = $handler->handle($data);
         }
         return $data;
     } else {
         $url = $request->toUrl($this->endpoint);
         $holder->msg .= $url . "\r\n";
         return $url;
     }
 }
开发者ID:zengdongbao,项目名称:ks3-php,代码行数:101,代码来源:Ks3Client.class.php


注:本文中的RequestCore::set_seek_position方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。