Python httplib.NO_CONTENT Examples

The following are 5 code examples of httplib.NO_CONTENT(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module httplib , or try the search function .
Example #1
Source File: http.py    From suds with GNU Lesser General Public License v3.0 6 votes vote down vote up
def send(self, request):
        url = self.__get_request_url_for_urllib(request)
        msg = request.message
        headers = request.headers
        try:
            u2request = urllib2.Request(url, msg, headers)
            self.addcookies(u2request)
            self.proxy = self.options.proxy
            request.headers.update(u2request.headers)
            log.debug('sending:\n%s', request)
            fp = self.u2open(u2request, timeout=request.timeout)
            self.getcookies(fp, u2request)
            headers = fp.headers
            if sys.version_info < (3, 0):
                headers = headers.dict
            reply = Reply(httplib.OK, headers, fp.read())
            log.debug('received:\n%s', reply)
            return reply
        except urllib2.HTTPError as e:
            if e.code not in (httplib.ACCEPTED, httplib.NO_CONTENT):
                raise TransportError(e.msg, e.code, e.fp) 
Example #2
Source File: test_api.py    From recipes-py with Apache License 2.0 5 votes vote down vote up
def _response(self, step_name, data, size, status_code, error_body):
    step_data = [
        self.m.json.output({
          'status_code': status_code,
          'success': status_code in (httplib.OK, httplib.NO_CONTENT),
          'size': size,
          'error_body': error_body,
        }, name='status_json'),
    ]
    if data:
      step_data.append(data)
    return self.step_data(step_name, *step_data) 
Example #3
Source File: client.py    From pykit with MIT License 5 votes vote down vote up
def _handle_server_response(self, response):

        if response.status in (httplib.OK, httplib.CREATED,
                               httplib.NO_CONTENT):
            return response

        logger.debug('invalid response status:{st} body:{body}'.format(
                     st=response.status, body=response.data))

        EtcdError.handle(response) 
Example #4
Source File: proxy.py    From ryu with Apache License 2.0 5 votes vote down vote up
def _do_request(address, path):
    conn = httplib.HTTPConnection(address)
    conn.request('GET', path)
    res = conn.getresponse()
    if res.status in (httplib.OK,
                      httplib.CREATED,
                      httplib.ACCEPTED,
                      httplib.NO_CONTENT):
        return res

    raise httplib.HTTPException(
        res, 'code %d reason %s' % (res.status, res.reason),
        res.getheaders(), res.read()) 
Example #5
Source File: stub_dispatcher.py    From python-compat-runtime with Apache License 2.0 5 votes vote down vote up
def _handle_delete(gcs_stub, filename):
  """Handle DELETE object."""
  if gcs_stub.delete_object(filename):
    return _FakeUrlFetchResult(httplib.NO_CONTENT, {}, '')
  else:
    return _FakeUrlFetchResult(httplib.NOT_FOUND, {}, '')