Select appropriate parser based on the request.

        :param request: the HTTP request
        :param resource: the invoked resource
433572
def select_parser(self, request, resource):
        

        # 1. get from resource
        if resource.mapper:
            return resource.mapper
        # 2. get from content type
        mapper_name = self._get_name_from_content_type(request)
        if mapper_name:
            return self._get_mapper(mapper_name)
        # 3. get from url
        mapper_name = self._get_name_from_url(request)
        if mapper_name:
            return self._get_mapper(mapper_name)
        # 4. use resource's default
        if resource.default_mapper:
            return resource.default_mapper
        # 5. use manager's default
        return self._get_default_mapper()
347987
def add_request(self, request):
        

        # Duplicate request name?
        if request.name in self.requests:
            raise ValueError('redefinition of request "{0}"'.format(request.name))
        self.requests[request.name] = request

        # Add the request URLs
        for method, url in request.urls:

            # URL with arguments?
            if RE_URL_ARG.search(url):
                request_regex = '^' + RE_URL_ARG_ESC.sub(r'/(?P<\1>[^/]+)', re.escape(url)) + '$'
                self.__request_regex.append((method, re.compile(request_regex), request))
            else:
                request_key = (method, url)
                if request_key in self.__request_urls:
                    raise ValueError('redefinition of request URL "{0}"'.format(url))
                self.__request_urls[request_key] = request
1343002
def request_host(request):
    
    url = request.get_full_url()
    parse_result = compat.urlparse.urlparse(url)
    scheme, host, port = parse_result.scheme, parse_result.hostname, parse_result.port
    try:
        port = int(port)
    except ValueError:
        pass
    if host == "":
        host = request.get_header("Host", "")

    if port != default_ports.get(scheme):
        host = "%s:%s" % (host, port)
    return host
554080
public void handleRequest(String request) {
        if (messageListener != null) {
            log.debug("Received Http request");
            messageListener.onInboundMessage(new RawMessage(request), null);
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Received Http request:" + NEWLINE + request);
            }
        }
    }
319252
public function parseRequest($request)
    {
        if (count($this->availableLanguages) > 0) {
            if (preg_match('/\/(' . implode('|', $this->availableLanguages) . ')(.*)/si', $request->url, $matches)) {
                Yii::$app->language = $matches[1];
            }
        }

        $res = parent::parseRequest($request);
        if (is_array($res)) {
            if (isset($res[1]['language']) && in_array($res[1]['language'], $this->availableLanguages)) {
                Yii::$app->language = $res[1]['language'];
            }
        }
        return $res;
    }
954213
def identify_request(request: RequestType) -> bool:
    
    # noinspection PyBroadException
    try:
        data = json.loads(decode_if_bytes(request.body))
        if "@context" in data:
            return True
    except Exception:
        pass
    return False
789819
async def get(self, request, resource=None, **kwargs):
        
        if resource is not None and resource != '':
            return self.to_simple(request, resource, **kwargs)

        return self.to_simple(request, self.collection, many=True, **kwargs)
1148707
def _parse_request_method(request: web.Request):
        
        method = request.headers.get(hdrs.ACCESS_CONTROL_REQUEST_METHOD)
        if method is None:
            raise web.HTTPForbidden(
                text="CORS preflight request failed: "
                     "'Access-Control-Request-Method' header is not specified")

        # FIXME: validate method string (ABNF: method = token), if parsing
        # fails, raise HTTPForbidden.

        return method
748145
def process_request(self, request):
        
        content_type = request.META.get('CONTENT_TYPE', '')
        for non_cacheable_type in self.non_cacheable_types:
            if non_cacheable_type in content_type:
                return
        request.body
12511
def auto_parser(parsers=(x_request_id, x_correlation_id, amazon_elb_trace_id)):
    

    for parser in parsers:
        request_id = parser()
        if request_id is not None:
            return request_id

    return None
1360756
def initialize_request(self, request, *args, **kwargs):
        
        parser_context = self.get_parser_context(request)

        return Request(
            request,
            parsers=self.get_parsers(),
            authenticators=self.get_authenticators(),
            negotiator=self.get_content_negotiator(),
            parser_context=parser_context
        )
891841
def prepare_request(self, *args, **kw):
        
        self.http_request = self.request_class(self.path, *args, **kw)
1202142
def _get_input_validator(self, request):
        

        method = request.method.upper()
        if method != 'POST':
            return self.representation
        elif self.post_representation:
            return self.post_representation
        else:
            return self.representation
494930
def _make_request(self, params, translation_url, headers):
        
        resp = requests.get(translation_url, params=params, headers=headers)
        resp.encoding = "UTF-8-sig"
        result = resp.json()
        return result
629975
public function parse(Request $request)
    {
        if ($request->has($this->name)) {
            $this->applied = true;
            $this->value   = filter_var($request->input($this->name), FILTER_VALIDATE_BOOLEAN);
        }
    }
423254
def parse_request() -> Dict[str, str]:
    
    in_lines = sys.stdin.readlines()
    LOGGER.debug('Received request "%s"', in_lines)

    request = {}
    for line in in_lines:
        # skip empty lines to be a bit resilient against protocol errors
        if not line.strip():
            continue

        parts = line.split('=', 1)
        assert len(parts) == 2
        request[parts[0].strip()] = parts[1].strip()

    return request
797109
def lookup(self, request: Request) -> List[Callable[[], Handler]]:
        
        key = request.__class__.__name__
        if key not in self._registry:
            if request.is_command():
                raise ConfigurationException("There is no handler registered for this request")
            elif request.is_event():
                return []  # type: Callable[[] Handler]

        return self._registry[key]