Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)
Esempio n. 6
0
    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)
Esempio n. 7
0
    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)
Esempio n. 8
0
 def send_response(self, code):
     """
     See Python's BaseHTTPRequestHandler.send_response().
     """
     BaseHTTPRequestHandler.send_response(self, code)
     self.send_header("Connection", "close")
Esempio n. 9
0
 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
Esempio n. 11
0
 def send_response(self, *args, **kwargs):
     BaseHTTPRequestHandler.send_response(self, *args, **kwargs)
     self.send_header('Access-Control-Allow-Origin', '*')
Esempio n. 12
0
 def send_response(self, *args, **kwargs):
     self._response_sent = True
     BaseHTTPRequestHandler.send_response(self, *args, **kwargs)
Esempio n. 13
0
 def send_response(self, code):
     """
     See Python's BaseHTTPRequestHandler.send_response().
     """
     BaseHTTPRequestHandler.send_response(self, code)
     self.send_header("Connection", "close")
Esempio n. 14
0
 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()
Esempio n. 15
0
 def send_response(self, code):
     BaseHTTPRequestHandler.send_response(self, code)
     self.send_header("Connection", "close")
Esempio n. 16
0
 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()