コード例 #1
0
 def dispatch(self, request, path, *args, **kwargs):
     """
     The parent implementation is to proxy the request and return it from the
     upstream server."""
     # with container(self.get_object()):
     response = None
     with container(self.get_object()), statsd.timer('proxy_wait'):
         self.upstream = self.base_url
         for _ in range(15):
             try:
                 if path and path[0] == "/":
                     path = path[1:]
                 response = super(DynProxyView,
                                  self).dispatch(request, path)
                 if "location" in response._headers:
                     response._headers["location"] = rewrite_redirect(
                         response, request)
                 break
             except:
                 time.sleep(1)
         self.get_object().cleanup()
     if not response:
         return HttpResponse(
             "Your app failed to boot, perhaps there is a syntax error in your code."
         )
     return response
コード例 #2
0
def test_rewrite_redirect():
    response = FakeObject()
    response._headers = {"location": ('Location', "http://localhost:9000/hello")}
    request = FakeObject()
    def uri():
        return "http://localhost:9000/12/result//asd"
    request.build_absolute_uri = uri
    expected = ('Location', "http://localhost:9000/12/result//hello/")
    result = rewrite_redirect(response, request)
    assert expected == result
コード例 #3
0
ファイル: views.py プロジェクト: arpheno/backendfail
 def dispatch(self, request, path, *args, **kwargs):
     """
     The parent implementation is to proxy the request and return it from the
     upstream server."""
     # with container(self.get_object()):
     response = None
     with container(self.get_object()),statsd.timer('proxy_wait'):
         self.upstream = self.base_url
         for _ in range(15):
             try:
                 if path and path[0] == "/":
                     path = path[1:]
                 response = super(DynProxyView, self).dispatch(request, path)
                 if "location" in response._headers:
                     response._headers["location"] = rewrite_redirect(response,
                                                                      request)
                 break
             except:
                 time.sleep(1)
         self.get_object().cleanup()
     if not response:
         return HttpResponse(
             "Your app failed to boot, perhaps there is a syntax error in your code.")
     return response