Changeset 942
- Timestamp:
- 07/23/08 18:47:30 (2 months ago)
- Files:
-
- branches/restful-service/lib/AkRequest.php (modified) (1 diff)
- branches/restful-service/test/unit2/AkRequest/AcceptHeader.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/restful-service/lib/AkRequest.php
r895 r942 331 331 private function parseMimeType($mime_type) 332 332 { 333 @list($type,$parameter_string) = explode(';',$mime_type );333 @list($type,$parameter_string) = explode(';',$mime_type,2); 334 334 $mime_type_struct = array(); 335 335 if ($parameter_string){ 336 parse_str($parameter_string,$mime_type_struct); 336 foreach (explode(';',$parameter_string) as $parameter){ 337 if (strstr($parameter,'=')){ 338 list($key,$value) = explode('=',$parameter); 339 $mime_type_struct[$key] = $value; 340 }else{ 341 $mime_type_struct[] = $parameter; 342 } 343 } 337 344 } 338 345 $mime_type_struct['type'] = trim($type); branches/restful-service/test/unit2/AkRequest/AcceptHeader.php
r892 r942 27 27 $this->Request->env['HTTP_ACCEPT'] = 'text/html'; 28 28 $this->assertEquals(array('type'=>'text/html','q'=>'1.0'),array_pop($this->Request->getAcceptHeader())); 29 } 30 31 function testMimetypeParserRecoginzesAdditionalParameters() 32 { 33 $this->Request->env['HTTP_ACCEPT'] = 'text/html;q=0.9;key=value;throw_away'; 34 $this->assertEquals(array('type'=>'text/html','q'=>'0.9','key'=>'value','throw_away'),array_pop($this->Request->getAcceptHeader())); 35 } 36 37 function testMimetypeParserHandleFalseParametersNice() 38 { 39 $this->Request->env['HTTP_ACCEPT'] = 'text/xml;throw_away'; 40 $this->assertEquals('xml',$this->Request->getFormat()); 29 41 } 30 42
