public static function getCharacterEncoding($response) { $content_type = $response->headers['Content-Type']; $parsed = http_parse_params($content_type); if (!empty($parsed->params[1]['charset'])) { return $parsed->params[1]['charset']; } else { return 'ISO-8859-1'; } }
public function parse() { $fields = array(); $iterator = new BoundaryIter($this->body, $this->boundary); while (false !== ($part = $iterator->getPart())) { // The headers from the multipart parsing are a bit crappy // as http_parse_params returns a lot of junk "data // structure", we need to take the time to clean the mess // because in fact, we need only a very limited set of // information. $type = 'FIELD'; $field = array(); $start = $part[1]; $end = $part[2]; foreach ($part[0] as $key => $val) { $params = http_parse_params($val); if ($key === 'Content-Disposition') { // Here we get if we have a POST or a FILE $filename = self::getHeaderOption('filename', $params); if (null !== $filename) { $type = 'FILE'; $field['filename'] = $filename; $field['size'] = $end - $start; $field['data'] = new FileStreamWrapper($this->body, $start, $end); } else { $data = new FileStreamWrapper($this->body, $start, $end); $field['data'] = $data->read(); } $field['name'] = self::getHeaderOption('name', $params); $field['of_type'] = $type; } if ($key === 'Content-Type') { $field['type'] = isset($params->params[0]) ? $params->params[0] : null; } } $fields[] = $field; } return $fields; }
public static function basic($input) { return http_parse_params($input); }
/** * Test Http functions. */ function test_functions() { http_cache_last_modified(); http_chunked_decode(); http_deflate(); http_inflate(); http_build_cookie(); http_date(); http_get_request_body_stream(); http_get_request_body(); http_get_request_headers(); http_match_etag(); http_match_modified(); http_match_request_header(); http_support(); http_negotiate_charset(); http_negotiate_content_type(); http_negotiate_language(); ob_deflatehandler(); ob_etaghandler(); ob_inflatehandler(); http_parse_cookie(); http_parse_headers(); http_parse_message(); http_parse_params(); http_persistent_handles_clean(); http_persistent_handles_count(); http_persistent_handles_ident(); http_get(); http_head(); http_post_data(); http_post_fields(); http_put_data(); http_put_file(); http_put_stream(); http_request_body_encode(); http_request_method_exists(); http_request_method_name(); http_request_method_register(); http_request_method_unregister(); http_request(); http_redirect(); http_send_content_disposition(); http_send_content_type(); http_send_data(); http_send_file(); http_send_last_modified(); http_send_status(); http_send_stream(); http_throttle(); http_build_str(); http_build_url(); }