Esempio n. 1
0
    def _new_no_content_resp(self, uri, log_it=False):
        '''
        Return a new NO_CONTENT httpResponse object. Optionally call the
        subscribed log handlers
        
        @param uri: URI string or request object
        
        @param log_it: Boolean that indicated whether to log request
        and response.  
        '''
        # accept a URI or a Request object
        if isinstance(uri, url_object):
            req = HTTPRequest(uri)
        elif isinstance(uri, HTTPRequest):
            req = uri
        else:
            msg = 'The uri parameter of xUrllib._new_content_resp() has to be of'
            msg += ' HTTPRequest of url_object type.'
            raise Exception( msg )

        # Work,
        no_content_response = httpResponse(NO_CONTENT, '', {}, uri, uri, msg='No Content')
        if log_it:
            # This also assigns the id to both objects.
            logHandler.logHandler().http_response(req, no_content_response)
        
        if no_content_response.id is None:
            no_content_response.id = seq_gen.inc()
            
        return no_content_response
Esempio n. 2
0
 def _new_no_content_resp(self, uri, log_it=False):
     '''
     Return a new NO_CONTENT httpResponse object. Optionally call the
     subscribed log handlers
     
     @param uri: URI string or request object
     @param log_it: Boolean that indicated whether to log request
         and response.        
     '''
     nc_resp = httpResponse(NO_CONTENT, '', {}, uri, uri, msg='No Content')
     if log_it:
         # accept a URI or a Request object
         if isinstance(uri, basestring):
             req = HTTPRequest(uri)
         else:
             req = uri
         # This also assign a the id to both objects.
         logHandler.logHandler().http_response(req, nc_resp)
     else:
         nc_resp.id = seq_gen.inc()
     return nc_resp