def send_response(self, code, message=None, size='-'): """ Send the response header and log the response code. Also send two standard headers with the server software version and the current date. | **param** code (int) | **param** message (str) | **param** size (str) """ BaseHTTPRequestHandler.send_response(self, code, message) BaseHTTPRequestHandler.log_request(self, code, size)
def send_response(self, code, message=None, size="-"): """ Send the response header and log the response code. Also send two standard headers with the server software version and the current date. | **param** code (int) | **param** message (str) | **param** size (str) """ BaseHTTPRequestHandler.send_response(self, code, message) BaseHTTPRequestHandler.log_request(self, code, size)
def send_response(self, code, message=None): # the BufferingHttpServer will send Connection: close , while # the BaseHTTPRequestHandler will only accept int code. # workaround both of them. if self.command == "PROPFIND" and int(code) == 404: kh = khtml_re.search(self.headers.get("User-Agent", "")) if kh and (kh.group(1) < "4.5"): # There is an ugly bug in all khtml < 4.5.x, where the 404 # response is treated as an immediate error, which would even # break the flow of a subsequent PUT request. At the same time, # the 200 response (rather than 207 with content) is treated # as "path not exist", so we send this instead # https://bugs.kde.org/show_bug.cgi?id=166081 code = 200 BaseHTTPRequestHandler.send_response(self, int(code), message)
def send_response(self, code, message=None): # the BufferingHttpServer will send Connection: close , while # the BaseHTTPRequestHandler will only accept int code. # workaround both of them. if self.command == 'PROPFIND' and int(code) == 404: kh = khtml_re.search(self.headers.get('User-Agent', '')) if kh and (kh.group(1) < '4.5'): # There is an ugly bug in all khtml < 4.5.x, where the 404 # response is treated as an immediate error, which would even # break the flow of a subsequent PUT request. At the same time, # the 200 response (rather than 207 with content) is treated # as "path not exist", so we send this instead # https://bugs.kde.org/show_bug.cgi?id=166081 code = 200 BaseHTTPRequestHandler.send_response(self, int(code), message)
def send_response(self, message=None, code=200): if self.response_sent == True: return self.response_sent = True return BaseHTTPRequestHandler.send_response(self, code, message)
def send_response(self, status_code, content=None, headers=None): """ Send a response back to the client with the HTTP `status_code` (int), `content` (str) and `headers` (dict). """ self.log_message( "Sent HTTP response: {0} with content '{1}' and headers {2}". format(status_code, content, headers)) if headers is None: headers = dict() BaseHTTPRequestHandler.send_response(self, status_code) for (key, value) in headers.items(): self.send_header(key, value) if len(headers) > 0: self.end_headers() if content is not None: self.wfile.write(content)
def send_response(self, status_code, content=None, headers=None): """ Send a response back to the client with the HTTP `status_code` (int), `content` (str) and `headers` (dict). """ self.log_message( "Sent HTTP response: {0} with content '{1}' and headers {2}".format(status_code, content, headers) ) if headers is None: headers = dict() BaseHTTPRequestHandler.send_response(self, status_code) for (key, value) in headers.items(): self.send_header(key, value) if len(headers) > 0: self.end_headers() if content is not None: self.wfile.write(content)
def send_response(self, code): """ See Python's BaseHTTPRequestHandler.send_response(). """ BaseHTTPRequestHandler.send_response(self, code) self.send_header("Connection", "close")
def send_response(self, *args, **kwargs): BaseHTTPRequestHandler.send_response(self, *args, **kwargs) if 'Origin' in self.headers: self.send_header('Access-Control-Allow-Origin', self.headers['Origin']) self.send_header('Access-Control-Allow-Methods', 'OPTIONS, GET, POST, DELETE') self.send_header('Access-Control-Allow-Headers', 'Content-Type')
def send_response(self, code, message=None): if self.response_code_sent: raise InvalidResponseException('response code already sent') BaseHTTPRequestHandler.send_response(self, code, message) self.response_code_sent = True
def send_response(self, *args, **kwargs): BaseHTTPRequestHandler.send_response(self, *args, **kwargs) self.send_header('Access-Control-Allow-Origin', '*')
def send_response(self, *args, **kwargs): self._response_sent = True BaseHTTPRequestHandler.send_response(self, *args, **kwargs)
def send_headers(self,code): BaseHTTPRequestHandler.send_response(self, code) self.send_header("Content-Type", "application/json") self.send_header("Access-Control-Allow-Origin", "*") self.end_headers()
def send_response(self, code): BaseHTTPRequestHandler.send_response(self, code) self.send_header("Connection", "close")
def send_headers(self, code): BaseHTTPRequestHandler.send_response(self, code) self.send_header("Content-Type", "application/json") self.send_header("Access-Control-Allow-Origin", "*") self.end_headers()