Parse request payload and return POST-vars

		:return: None or dictionary of names and tuples of values
168876
def post_vars(self):
		
		if self.method() != 'POST':
			raise RuntimeError('Unable to return post vars for non-get method')

		content_type = self.content_type()
		if content_type is None or content_type.lower() != 'application/x-www-form-urlencoded':
			raise RuntimeError('Unable to return post vars with invalid content-type request')

		request_data = self.request_data()
		request_data = request_data.decode() if request_data is not None else ''
		re_search = WWebRequestProto.post_vars_re.search(request_data)
		if re_search is not None:
			return urllib.parse.parse_qs(re_search.group(1), keep_blank_values=1)
341723
def parse_request(self, request, parameters, fake_method=None):
        '''
        
        '''
        return (fake_method or request.method,
                request.build_absolute_uri(),
                request.META,
                (dict(request.POST.iteritems())
                    if request.method == 'POST'
                    else parameters))
717973
def _get_request_messages(self, request):
        
        data = request.get_data(as_text=True)
        try:
            msg = self.json_decoder.decode(data)
        except Exception:
            raise ParseError("Could not parse request data '{}'".format(data))
        if isinstance(msg, list):
            return msg
        else:
            return [msg]
86773
def json(self, var, default=NOTSET):
        
        return self.get_value(var, cast=json.loads, default=default)
1322202
def _parse_response(response, post_request=False):
        
        data = response.json()

        if not response.ok:
            utils.error_message_and_exit('Push Api Error:', data)

        if post_request and not data['success']:
            raise Exception('Push Api Error: [%s]' % data['error'])

        return data
306998
def to_postdata(self):
        """"""
        items = []
        for k, v in sorted(self.items()):  # predictable for testing
            items.append((k.encode('utf-8'), to_utf8_optional_iterator(v)))

        # tell urlencode to deal with sequence values and map them correctly
        # to resulting querystring. for example self["k"] = ["v1", "v2"] will
        # result in 'k=v1&k=v2' and not k=%5B%27v1%27%2C+%27v2%27%5D
        return urlencode(items, True).replace('+', '%20').encode('ascii')
355546
def get_post_data(self):
        '''
        
        '''
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_arguments(key)[0]
        return post_data
970412
def x_www_form_urlencoded(post_data):
    
    if isinstance(post_data, dict):
        return "&".join([
            u"{}={}".format(key, value)
            for key, value in post_data.items()
        ])
    else:
        return post_data
988996
def payload(self):
        
        if self._content_type is not None:
            try:
                return self._payload[self._content_type]
            except KeyError:
                raise KeyError("Content-Type not available")
        else:

            if defines.Content_types["text/plain"] in self._payload:
                return self._payload[defines.Content_types["text/plain"]]
            else:
                val = list(self._payload.keys())
                return val[0], self._payload[val[0]]
243223
def parse_request(self, request, parameters=None, fake_method=None):
        '''
        
        '''
        return (request.method,
                request.url,
                request.headers,
                request.POST.mixed())
40234
def fetch_post_data(self):
        '''
        
        '''
        post_data = {}
        ext_dic = {}
        for key in self.request.arguments:
            if key.startswith('ext_') or key.startswith('tag_'):
                ext_dic[key] = self.get_argument(key)
            else:
                post_data[key] = self.get_arguments(key)[0]

        post_data['user_name'] = self.userinfo.user_name
        post_data['kind'] = self.kind

        # append external infor.

        if 'tags' in post_data:
            ext_dic['def_tag_arr'] = [x.strip() for x
                                      in post_data['tags'].strip().strip(',').split(',')]
        ext_dic = dict(ext_dic, **self.ext_post_data(postdata=post_data))

        return (post_data, ext_dic)
1347904
def decode_response(client_message, to_object=None):
    
    parameters = dict(response=None)
    parameters['response'] = client_message.read_str()
    return parameters
899000
def _extract_params(self):
        
        # Because in this endpoint we handle both GET
        # and POST request.
        query_dict = (self.request.POST if self.request.method == 'POST'
                      else self.request.GET)

        self.params['client_id'] = query_dict.get('client_id', '')
        self.params['redirect_uri'] = query_dict.get('redirect_uri', '')
        self.params['response_type'] = query_dict.get('response_type', '')
        self.params['scope'] = query_dict.get('scope', '').split()
        self.params['state'] = query_dict.get('state', '')
        self.params['nonce'] = query_dict.get('nonce', '')

        self.params['prompt'] = self._allowed_prompt_params.intersection(
            set(query_dict.get('prompt', '').split()))

        self.params['code_challenge'] = query_dict.get('code_challenge', '')
        self.params['code_challenge_method'] = query_dict.get('code_challenge_method', '')
874018
def parse(self, mimetypes):
        

        self._parse_top_level_content_type()

        link = 'tools.ietf.org/html/rfc2388'
        parts = cgi.FieldStorage(
            fp=self.req.stream,
            environ=self.req.env,
        )

        if not parts:
            self.fail('A payload in the body of your request is required '
                      '& must be encapsulated by the boundary with proper '
                      'headers according to RFC 2388', link)
        elif len(parts) > 1:
            self.fail('Currently, only 1 upload at a time is allowed. Please '
                      'break up your request into %s individual requests & '
                      'retry' % len(parts), link)
        else:
            self._parse_part(parts.list[0], mimetypes)
            return parts
1238228
def request_payload(cls, request, request_id):
        ''''''
        if isinstance(request.args, dict):
            raise ProtocolError.invalid_args(
                'JSONRPCv1 does not support named arguments')
        return {
            'method': request.method,
            'params': request.args,
            'id': request_id
        }
1334189
def _get_path_params(match):
    
    result = {}
    for var_name, value in match.groupdict().iteritems():
      actual_var_name = ApiConfigManager._from_safe_path_param_name(var_name)
      result[actual_var_name] = urllib.unquote_plus(value)
    return result
21662
def parse_request():
    """"""
    find = None
    if request.endpoint is not None:
        find = PATTERN_ENDPOINT.findall(request.endpoint)
    if not find:
        raise ValueError("invalid endpoint %s" % request.endpoint)
    __, resource, action_name = find[0]
    if action_name:
        action = request.method.lower() + "_" + action_name
    else:
        action = request.method.lower()
    return resource, action