-
-
Save dec1985/c937a09375eeed5a5c0d0d7813017097 to your computer and use it in GitHub Desktop.
Revisions
-
JustinTArthur revised this gist
Oct 21, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ def reverse_proxy(request): import requests requestor = getattr(requests, request.method.lower()) proxied_response = requestor(url, data=request.body, files=request.FILES) from django.http.response import HttpResponse response = HttpResponse(proxied_response.content, content_type=proxied_response.headers.get('content-type')) -
JustinTArthur revised this gist
Jun 4, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ @csrf_exempt def reverse_proxy(request): """ Reverse proxy for a remote service. """ path = request.get_full_path() #Optionally, rewrite the path to fit whatever service we're proxying to. -
JustinTArthur revised this gist
Jun 4, 2013 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,21 @@ from django.views.decorators.csrf import csrf_exempt @csrf_exempt def reverse_proxy(request): """ Reverse proxy for a remote service that is useful for local testing. """ path = request.get_full_path() #Optionally, rewrite the path to fit whatever service we're proxying to. url = "http://%s%s" % ("my_server.lol:9200", path) import requests requestor = getattr(requests, request.method.lower()) proxied_response = requestor(url, data=request.REQUEST, files=request.FILES) from django.http.response import HttpResponse response = HttpResponse(proxied_response.content, content_type=proxied_response.headers.get('content-type')) for header_key, header_value in proxied_response.headers.iteritems(): response[header_key] = header_value -
JustinTArthur renamed this gist
Jun 4, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
JustinTArthur revised this gist
Jun 4, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ @csrf_exempt def reverse_proxy(request): from django.http.response import HttpResponse import requests """ -
JustinTArthur created this gist
Jun 4, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ @csrf_exempt def search_api(request): from django.http.response import HttpResponse import requests """ Reverse proxy for a remote service. To be used for local development/testing. Otherwise, consider nginx. """ path = request.get_full_path() #Optionally, rewrite the path to fit whatever service we're proxying to. url = "http://%s%s" % ("my_server.lol:9200", path) requestor = getattr(requests,request.method.lower()) proxied_response = requestor(url, data=request.REQUEST, files=request.FILES) response = HttpResponse(proxied_response.content, content_type=proxied_response.headers.get('content-type')) for header_key, header_value in proxied_response.headers.iteritems(): response[header_key] = header_value return response