Changeset 92707 in webkit


Ignore:
Timestamp:
Aug 9, 2011 2:17:42 PM (13 years ago)
Author:
abarth@webkit.org
Message:

Enable CORS for garden-o-matic
https://bugs.webkit.org/show_bug.cgi?id=65936

Reviewed by Dimitri Glazkov.

This patch will allow the hosted instance of garden-o-matic to
communicate with the local server.

  • Scripts/webkitpy/tool/servers/gardeningserver.py:
  • Scripts/webkitpy/tool/servers/reflectionhandler.py:
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r92702 r92707  
     12011-08-09  Adam Barth  <abarth@webkit.org>
     2
     3        Enable CORS for garden-o-matic
     4        https://bugs.webkit.org/show_bug.cgi?id=65936
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        This patch will allow the hosted instance of garden-o-matic to
     9        communicate with the local server.
     10
     11        * Scripts/webkitpy/tool/servers/gardeningserver.py:
     12        * Scripts/webkitpy/tool/servers/reflectionhandler.py:
     13
    1142011-08-09  Adam Barth  <abarth@webkit.org>
    215
  • trunk/Tools/Scripts/webkitpy/tool/servers/gardeningserver.py

    r92636 r92707  
    104104        "TestFailures")
    105105
     106    allow_cross_origin_requests = True
     107
    106108    def _run_webkit_patch(self, args):
    107109        return self.server.tool.executive.run_command([self.server.tool.path()] + args, cwd=self.server.tool.scm().checkout_root)
  • trunk/Tools/Scripts/webkitpy/tool/servers/reflectionhandler.py

    r92346 r92707  
    5656    STATIC_FILE_DIRECTORY = None
    5757
     58    # Setting this flag to True causes the server to send
     59    #   Access-Control-Allow-Origin: *
     60    # with every response.
     61    allow_cross_origin_requests = False
     62
    5863    def do_GET(self):
    5964        self._handle_request()
     
    101106        threading.Thread(target=lambda: self.server.shutdown()).start()
    102107
     108    def _send_access_control_header(self):
     109        if self.allow_cross_origin_requests:
     110            self.send_header('Access-Control-Allow-Origin', '*')
     111
    103112    def _serve_text(self, text):
    104113        self.send_response(200)
     114        self._send_access_control_header()
    105115        self.send_header("Content-type", "text/plain")
    106116        self.end_headers()
     
    109119    def _serve_json(self, json_object):
    110120        self.send_response(200)
     121        self._send_access_control_header()
    111122        self.send_header('Content-type', 'application/json')
    112123        self.end_headers()
     
    119130        with codecs.open(file_path, "rb") as static_file:
    120131            self.send_response(200)
     132            self._send_access_control_header()
    121133            self.send_header("Content-Length", os.path.getsize(file_path))
    122134            mime_type, encoding = mimetypes.guess_type(file_path)
Note: See TracChangeset for help on using the changeset viewer.