Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an everything method {ANYTHING+COOKIES} #603

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions httpbin/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,118 @@ def view_anything(anything=None):
)


@app.route("/everything", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "TRACE"])
@app.route(
"/everything/<path:everything>",
methods=["GET", "POST", "PUT", "DELETE", "PATCH", "TRACE"],
)
def view_everything(everything=None):
"""Returns everything passed in request data.
---
tags:
- Everything
produces:
- application/json
responses:
200:
description: Everything passed in request
"""
try:
cookies = dict(request.cookies.items())
except:
cookies = {}

dict_to_return = get_dict(
"url",
"args",
"headers",
"origin",
"method",
"form",
"data",
"files",
"json",
)
dict_to_return['cookies'] = cookies

return jsonify(
dict_to_return
)


@app.route("/the_proxy_everything", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "TRACE"])
def the_proxy_everything(everything=None):
"""Returns everything passed in request data.
---
tags:
- Everything
produces:
- application/json
responses:
200:
description: Everything passed in request
"""
try:
cookies = dict(request.cookies.items())
except:
cookies = {}

dict_to_return = get_dict(
"url",
"args",
"headers",
"origin",
"method",
"form",
"data",
"files",
"json",
)
dict_to_return['cookies'] = cookies

return jsonify(
dict_to_return
)


@app.route("/proxy_everything", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "TRACE"])
@app.route(
"/proxy_everything/<path:proxy_everything>",
methods=["GET", "POST", "PUT", "DELETE", "PATCH", "TRACE"],
)
def proxy_everything(everything=None):
"""Returns everything passed in request data.
---
tags:
- Everything
produces:
- application/json
responses:
200:
description: Everything passed in request
"""
try:
cookies = dict(request.cookies.items())
except:
cookies = {}

dict_to_return = get_dict(
"url",
"args",
"headers",
"origin",
"method",
"form",
"data",
"files",
"json",
)
dict_to_return['cookies'] = cookies

return jsonify(
dict_to_return
)

@app.route("/post", methods=("POST",))
def view_post():
"""The request's POST parameters.
Expand Down