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


PHP Header::getParams方法代码示例

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


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

示例1: getHandshake

	public function getHandshake($buffer) {
		$header = new Header($buffer);
        $params = $header->getParams();;
        
        if (isset($params['Sec-WebSocket-Key'])) {
	        $response = "HTTP/1.1 101 Switching Protocols\r\n";
	        $response .= "Upgrade: websocket\r\n";
	        $response .= "Connection: Upgrade\r\n";
	        $response .= "Sec-WebSocket-Accept: $acceptKey";
	        $response .= "\0";
        }
        else {
			$pattern = '/[^\d]*/';
			$replacement = '';
			$numkey1 = preg_replace($pattern, $replacement, $params['Sec-WebSocket-Key1']);
			$numkey2 = preg_replace($pattern, $replacement, $params['Sec-WebSocket-Key2']);
			$pattern = '/[^ ]*/';
			$replacement = '';
			$spaces1 = strlen(preg_replace($pattern, $replacement, $params['Sec-WebSocket-Key1']));
			$spaces2 = strlen(preg_replace($pattern, $replacement, $params['Sec-WebSocket-Key2']));
			$hashData = md5( pack("N", $numkey1/$spaces1) . pack("N", $numkey2/$spaces2) . $header->getMessage(), true);
        	
			$response = "HTTP/1.1 101 WebSocket Protocol Handshake\r\n";
			$response .= "Upgrade: WebSocket\r\n";
			$response .= "Connection: Upgrade\r\n";
			$response .= "Sec-WebSocket-Origin: " . $params['Origin'] . "\r\n";
			$response .= "Sec-WebSocket-Location: ws://" . "{$this->address}:{$this->port}" . $header->getResource() . "\r\n";
			$response .= "\r\n";
			$response .= $hashData;
			$response .= "\0";
        }
        return $response;
	}
开发者ID:renq,项目名称:HTML5-Chat,代码行数:33,代码来源:WebSocket.php

示例2: InvalidArgumentException

 /**
  * @param Header $contentType
  * @throws InvalidArgumentException
  */
 function __construct(Header $contentType)
 {
     if (strcasecmp($contentType->name, "Content-Type")) {
         throw new InvalidArgumentException("Expected Content-Type header, got " . $contentType->name);
     }
     $vapi = static::version();
     $this->type = preg_replace("/\n\t\t\t(?:application\\/(?:vnd\\.github(?:\\.v{$vapi})?)?)\n\t\t\t(?|\n\t\t\t\t\t\\.\t\t\t\t\t([^.+]+)\n\t\t\t\t|\t(?:\\.[^.+]+)?\\+?\t(json)\n\t\t\t)/x", "\\1", current(array_keys($contentType->getParams()->params)));
 }
开发者ID:m6w6,项目名称:seekat,代码行数:12,代码来源:ContentType.php


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