示例#1
0
文件: httpserver.py 项目: f3at/feat
 def set_response_code(self, code, message=None):
     assert not self.writing, "Header already sent"
     self.status_code = code
     if message:
         self.status_message = message
     else:
         self.status_message = http.get_status_message(self.status_code)
示例#2
0
文件: httpserver.py 项目: f3at/feat
    def __init__(self, channel, info, active, code, message=None):
        BaseRequest.__init__(self, channel)

        self.protocol = info.protocol
        self.status_code = code
        self.status_message = http.get_status_message(self.status_code)
        self.persistent = False
        if active:
            self.activate()
示例#3
0
文件: httpserver.py 项目: f3at/feat
    def __init__(self, channel, info, active):
        log.Logger.__init__(self, channel)

        peer = channel.transport.getPeer()
        self.log_name = "%s:%s" % (peer.host, peer.port)
        self.debug('Creating %s', self.log_ident)

        BaseRequest.__init__(self, channel)

        self.request_protocol = info.protocol

        self.method = info.method
        self.uri = info.uri

        self._body_length = info.length
        self._received_headers = {}
        self._received_cookies = {}
        self._received_length = None
        self.received_bytes = 0

        self.protocol = info.protocol

        self._headers = {}
        self._cookies = {}

        self._length = None # No length by default
        self.bytes_sent = 0 # Bytes of BODY written (headers do not count)

        self.initiated = False # If the request has been initiated
        self.activated = False # If the request can write to the channel
        self.writing = False   # If already started writing data
        self.finished = False  # If the request is finished
        self.persistent = True # If the connection must be kept
        self.received = False  # If all body content received

        self.status_code = http.Status.OK
        self.status_message = http.get_status_message(self.status_code)

        self._parse_headers(info.headers)

        self.transport_activated = False
        self.transport = None
        if not active:
            self.transport = StringTransport()
示例#4
0
文件: httpserver.py 项目: f3at/feat
 def respond():
     msg = message or http.get_status_message(status_code)
     protocol = self._protocol or http.Protocols.HTTP10
     resp = "%s %d %s\r\n\r\n" % (protocol.name, status_code, msg)
     self.transport.write(resp)