Interpret the HTTP request
557131
public function handle($server, $get, $post)
	{
		$smalldb = null;

		// Convert current path to array and to string (result: $path is array, $path_str is string)
		$path = trim(isset($server['PATH_INFO']) ? $server['PATH_INFO'] : '', '/');
		$path = ($path == '' ? array() : explode('/', $path));

		// Get '!action'
		$path_tail = end($path);
		if (strpos($path_tail, '!') !== FALSE) {
			list($path_tail, $action, ) = explode('!', $path_tail, 3); // drop extra '!'
			if ($path_tail != '') {
				$path[key($path)] = $path_tail;
			} else {
				unset($path[key($path)]);
			}
		} else {
			$action = null;
		}
		$id = $path;

		// Do something useful
		if (!empty($path)) {
			if ($action !== null) {
				if ($server['REQUEST_METHOD'] == 'POST') {
					// Invoke transition
					$args = isset($post['args']) ? $post['args'] : [];
					return $this->handler->invokeTransition($id, $action, $args);
				} else {
					// Show transition
					return $this->handler->checkTransition($id, $action);
				}
			} else if (!empty($get)) {
				// Get view(s)
				return $this->handler->readViews($id, array_keys($get));
			} else {
				// Get properties
				return $this->handler->readState($id);
			}
		} else if (!empty($get)) {
			// Listing
			return $this->handler->listing($get);
		} else {
			// Nothing, just list known types
			return $this->handler->getKnownTypes();
		}
	}
794864
async def request(self):
        '''
        '''
        request_headers = self.request_headers()
        environ = self.environ
        method = environ['REQUEST_METHOD']
        data = None
        if method in ENCODE_BODY_METHODS:
            data = DataIterator(self)
        http = self.wsgi.http_client
        try:
            await http.request(method,
                               environ['RAW_URI'],
                               data=data,
                               headers=request_headers,
                               version=environ['SERVER_PROTOCOL'],
                               pre_request=self.pre_request)
        except Exception as exc:
            self.error(exc)
132708
def request(http_method, path, body = '', headers = {})
      puts "#{http_method}: #{path} - [#{body}]" if @http_debug
      @request_client.request(http_method, path, body, headers)
    end
775308
function Request(httpClient, url, method, headers, params, payload) {
    url = urlparse.parse(url, true); // query string parsing
    this.httpClient   = httpClient;
    this.scheme       = url.protocol.substr(0, url.protocol.length - 1);
    this.port         = url.port ? url.port : (this.scheme === 'http' ? 80 : 443);
    this.host         = url.hostname;
    this.method       = method;
    this.path_info    = url.pathname;
    this.query_string = url.query || {};
    this.headers      = headers || {},
    this.params       = params || {};
    this.payload      = payload || null;
    this.headers['host'] = url.hostname;
}
102250
function Request(reqBytes){
  var parsed;
  var err

  try {
    parsed = types.Request.decode(reqBytes);
  } catch (e) {
    err = e;
  }


  //Check for request errors here
  if(err){
    this.BadRequest = true;
    this.errCode = types.CodeType.EncodingError;
    this.errMsg = "The request failed to be decoded"
  } else if(!types.methodLookup[parsed.type]){
    //Request type not recognized
    //Make a request object for the error
    this.BadRequest = true;
    this.errCode = types.CodeType.UnknownRequest;
    this.errMsg = "The request type was not understood"
  } else {

    this.BadRequest = false; 
    this.type = parsed.type;
    this.method = types.methodLookup[this.type];
    this.data = parsed.data.buffer.slice(parsed.data.offset);
    this.dataLength = parsed.data.limit - parsed.data.offset;
    this.dataLittle = parsed.data.littleEndian;
    this.key = parsed.key;
    this.value = parsed.value;
  }
}
644894
def http_response(self, request):
        '''
        '''
        content_types = request.content_types
        if not content_types or self._content_type in content_types:
            response = request.response
            response.content_type = self._content_type
            response.encoding = self.charset
            response.content = self.to_bytes()
            return response
        else:
            raise HttpException(status=415, msg=request.content_types)
1356215
def _request(self, path, method, body=None):
        ""
        h = httplib2.Http()
        resp, content = h.request(
            self.base_url + path,
            method,
            body = json.dumps(body),
        )
        if resp['status'] == "200":
            return json.loads(content)
        else:
            raise IOError(
                "Got %s reponse from server (%s)" % (
                    resp['status'],
                    content,
                )
            )
1363611
def _construct_request(self):
        
        if self.parsed_endpoint.scheme == 'https':
            conn = httplib.HTTPSConnection(self.parsed_endpoint.netloc)
        else:
            conn = httplib.HTTPConnection(self.parsed_endpoint.netloc)
        head = {
            "Accept": "application/json",
            "User-Agent": USER_AGENT,
            API_TOKEN_HEADER_NAME: self.api_token,
        }
        if self.api_version in ['0.1', '0.01a']:
            head[API_VERSION_HEADER_NAME] = self.api_version
        return conn, head
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
1355022
def __request(self, url, params):
        
        log.debug('request: %s %s' %(url, str(params)))
        try:
            response = urlopen(url, urlencode(params)).read()
            if params.get('action') != 'data':
                log.debug('response: %s' % response)
            if params.get('action', None) == 'data':
                return response
            else:
                return json.loads(response)
        except TypeError, e:
            log.exception('request error')
            raise ServerError(e)
        except IOError, e:
            log.error('request error: %s' % str(e))
            raise ServerError(e)
364531
function (request) {
      // Extract information from request.  The toString() call converts the
      // payload from a binary Buffer into a string, decoded using UTF-8
      // character encoding.
      console.log('Service received request payload: ' +
        request.payload.toString())
      // Create the response message
      var response = new dxl.Response(request)
      // Populate the response payload
      response.payload = 'pong'
      // Send the response
      client.sendResponse(response)
    }
977373
def __request(self, method, url, request_args, headers=None, stream=False):
        
        func = getattr(self.client, method)
        headers = headers if headers else {}
        response = None
        try:
            logger.info("performing request %s", url)
            response = func(url, stream=stream, headers=headers,
                            **request_args)
        except requests.RequestException as err:
            logger.error("request %s failed [%s]", url, err)
            raise err

        # Handle error responses
        if response.status_code >= 400:
            logger.error("request %s failed [%d,%s]",
                         url,
                         response.status_code,
                         response.content.decode('utf-8'))
            raise V20Error(response.status_code,
                           response.content.decode('utf-8'))
        return response
1262717
def get_http_response(self):
        """"""
        return _get_response(
            code=self.code,
            body=str(self),
            headers={
                'Content-Type': 'text/plain'
            }
        )
1049614
def _parse_request(self):
        '''
        
        '''
        self.req_method = 'unknown'
        self.req_params = {}
        self.req_rpc_version = '2.0'
        self.req_id = 0
        self.data = self.rfile.read(int(self.headers.get('content-length')))
        data_dict = json.loads(self.data)
        self.req_method = data_dict['method']
        self.req_params = decode_data(data_dict['params'])
        self.req_rpc_version = data_dict['jsonrpc']
        self.req_id = data_dict['id']
539867
function httpRequest(url) {
    var deferred = Q.defer();
    request(url, function(err, response, body) {
      if (err) {
        deferred.reject(new Error(err));
      } else if (!err && response.statusCode !== 200) {
        deferred.reject(new Error(response.statusCode));
      } else {
        deferred.resolve(body);
      }
    });
    return deferred.promise;
  }
914849
def process_http_request(res)
      case res
      when HTTP_SUCCESS
        Log.debug('Http success')
        res
      when HTTP_CLIENT_ERROR
        fail Error.from_http_response(res)
      else
        Log.debug('Http error')
        Log.debug(res.body)
        res.error!
      end
    end
1036807
def http_request(action, data, method = 'POST', binary_key = nil)
      data = flatten_nested_hash(data, false)

      uri = "#{@api_uri}/#{action}"
      if method != 'POST'
        uri += "?" + data.map{ |key, value| "#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}" }.join("&")
      end

      req = nil
      headers = {"User-Agent" => "Sailthru API Ruby Client #{Sailthru::VERSION}"}

      _uri  = URI.parse(uri)

      if method == 'POST'
        req = set_up_post_request(
          _uri, data, headers, binary_key
        )

      else
        request_uri = "#{_uri.path}?#{_uri.query}"
        if method == 'DELETE'
          req = Net::HTTP::Delete.new(request_uri, headers)
        else
          req = Net::HTTP::Get.new(request_uri, headers)
        end
      end

      begin
        http = Net::HTTP::Proxy(@proxy_host, @proxy_port).new(_uri.host, _uri.port)

        if _uri.scheme == 'https'
          http.ssl_version = :TLSv1
          http.use_ssl = true
          http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @verify_ssl != true  # some openSSL client doesn't work without doing this
          http.ssl_timeout = @opts[:http_ssl_timeout] || 5
        end
        http.open_timeout = @opts[:http_open_timeout] || 5
        http.read_timeout = @opts[:http_read_timeout] || 10
        http.close_on_empty_response = @opts[:http_close_on_empty_response] || true

        response = http.start do
          http.request(req)
        end

      rescue Timeout::Error, Errno::ETIMEDOUT => e
        raise UnavailableError, "Timed out: #{_uri}"
      rescue => e
        raise ClientError, "Unable to open stream to #{_uri}: #{e.message}"
      end

      save_rate_limit_info(action, method, response)

      response.body || raise(ClientError, "No response received from stream: #{_uri}")
    end