示例#1
0
文件: request.php 项目: rgantt/sake
 protected function parse_formatted_request_parameters()
 {
     if ($this->content_length() == 0) {
         return array();
     }
     $mpb = self::extract_multipart_boundary($this->content_type_with_parameters());
     if (count($mpb) > 1) {
         list($content_type, $boundary) = $mpb;
     } else {
         $content_type = $mpb;
     }
     # Don't parse params for unknown requests
     if (empty($content_type)) {
         return array();
     }
     $mime_type = \mime\type::lookup($content_type);
     $strategy = base::$param_parsers[strtoupper($mime_type->symbol)];
     $body = $strategy && $strategy != 'multipart_form' ? $this->raw_post() : $this->body();
     try {
         switch ($strategy) {
             case 'url_encoded_form':
                 self::clean_up_ajax_request_body($body);
                 return self::parse_query_parameters($body);
             case 'multipart_form':
                 return self::parse_multipart_form_parameters($body, $boundary, $content_length, $env);
             case 'xml_simple':
             case 'xml_node':
                 break;
             case 'yaml':
                 return yaml::load($body);
                 break;
             default:
                 return array();
         }
     } catch (\biru_controller\sake_exception $e) {
         throw $e;
     }
 }