def _send_head(self, clength, last_modified=date_time_string()): self.write_response(200) # self.write_header("Content-type", ctype) self.write_header("Content-Length", clength) self.write_header("Last-Modified", last_modified) self.write_header("Access-Control-Allow-Origin", "http://%s:%d" % (HOST, PORT)) self.end_headers()
def write_response(self, code, msg=None): logging.info("%s, code,: %s." % (self.request_line, code)) #response-line response_line = '%s %d %s\r\n' % (self.default_http_version, code, msg) self.write_content(response_line) #response-header self.write_header( 'Server', '%s: %s' % (self.server.server_name, self.server.version)) self.write_header('Date', date_time_string())
def write_response(self, code, msg=None): logging.info('%s, code: %s' % (self.request_line, code)) if msg is None: msg = self.responses[code][0] response_line = '%s %d %s\r\n' % (self.default_http_version, code, msg) self.write_content(response_line) self.write_header('Server', '%s : %s' % (self.server.server_name, self.server.version)) self.write_header('Date', date_time_string()) pass
def write_response(self, code, msg=None): if msg == None: msg = self.responses[code][0] # 状态行 response_line = '%s %d %s \r\n' % (self.default_http_version, code, msg) self.write_content(response_line) self.write_header( 'Server', '%s: %s' % (self.server.server_name, self.server.version)) self.write_header('Date', date_time_string())
def write_response(self, code, msg=None): #code和msg分别是应答的状态码和状态解释 logging.info('%s, code: %s.' % (self.request_line, code)) if msg == None: msg = self.responses[code][0] #状态行 response_line = '%s %d %s\r\n' % (self.default_http_version, code, msg) self.write_content(response_line) #应答头 self.write_header( 'Server', '%s: %s' % (self.server.server_name, self.server.version)) self.write_header('Date', date_time_string())
def write_response(self, code, msg=None): logging.info('%s code:%s' % (self.request_line, code)) # 控制台日志打印 if msg is None: # 设置状态信息 msg = self.responses[code][0] # 写入状态行 response_line = '%s %d %s\r\n' % (self.default_http_version, code, msg) self.write_content(response_line) # 写入服务器类型,日期响应头 self.write_headers( 'Server', '%s: %s' % (self.server_socket.server_name, self.server_socket.version)) self.write_headers('Date', date_time_string())