This is a simple proxy web app that makes POST requests by requesting GET payloads to this.
Last active
December 13, 2015 20:29
-
-
Save dahlia/4970516 to your computer and use it in GitHub Desktop.
This is a simple proxy web app that makes POST requests by requesting GET payloads to this.
This file contains 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 characters
.*.swp | |
*.pyc |
This file contains 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 characters
application: simple-get2post | |
version: 1 | |
runtime: python27 | |
api_version: 1 | |
threadsafe: yes | |
handlers: | |
- url: .* | |
script: get2post.app | |
libraries: | |
- name: webapp2 | |
version: "2.5.2" |
This file contains 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 characters
import urllib | |
from google.appengine.api.urlfetch import fetch | |
from webapp2 import RequestHandler, WSGIApplication | |
class TransferHandler(RequestHandler): | |
def get(self, scheme, url): | |
url = '{0}://{1}'.format(scheme, url) | |
query = {} | |
data = {} | |
for key, value in self.request.GET.items(): | |
if key.startswith('get.'): | |
query[key[4:]] = value | |
elif key.startswith('post.'): | |
data[key[5:]] = value | |
if query: | |
url += '?' + urllib.urlencode(query) | |
payload = urllib.urlencode(data) | |
response = fetch(url, payload=payload, method='POST') | |
self.response.status_int = response.status_code | |
for header, value in response.headers.items(): | |
self.response.headers[header] = value | |
self.response.write(response.content) | |
app = WSGIApplication([ | |
('/(?P<scheme>https?)/(?P<url>.+)', TransferHandler) | |
], debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment