From 6d8240b693800e533ab0f138dca35d233623aa32 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 13 Jun 2011 09:07:30 -0400 Subject: [PATCH 1/3] `/cookies/set` endpoint --- README.md | 4 ++-- httpbin/core.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c7df1b5..04688db 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,13 @@ httpbin(1): HTTP Client Testing Service `/status/:code` Returns given HTTP Status code. `/redirect/:n` 302 Redirects *n* times. `/cookies` Returns cookie data. -`/set-cookie/:name/:value` Sets a simple cookie. +`/cookies/set/:name/:value` Sets a simple cookie. ## DESCRIPTION Testing an HTTP Library can become difficult sometimes. PostBin.org is fantastic -for testing POST requests, but not much else. This exists to cover all kinds of HTTP +for testing POST requests, but not much else. This exists to cover all kinds of HTTP scenarios. Additional endpoints are being considered: `/basic-auth`, `/deflate`, *&c*. All endpoint responses are JSON-encoded. diff --git a/httpbin/core.py b/httpbin/core.py index 6c1634d..ce7d1df 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -186,7 +186,7 @@ def view_cookies(): return request.cookies -@app.route('/set-cookie//') +@app.route('/cookies/set//') def set_cookie(name, value): """Sets a cookie and redirects to cookie list.""" From 53441fe9faf39dbb0c9d823ae6522774988c45eb Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 13 Jun 2011 09:08:25 -0400 Subject: [PATCH 2/3] Add Zbigniew Siciarz to authors --- AUTHORS | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..99c02d0 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,13 @@ +HttpBin is written and maintained by Kenneth Reitz and +various contributors: + +Development Lead +```````````````` + +- Kenneth Reitz <_@kennethreitz.com> + + +Patches and Suggestions +``````````````````````` + +- Zbigniew Siciarz \ No newline at end of file From dce77924c6e8cfd0a081eae8d7f2a9a84fa0d64e Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 13 Jun 2011 09:10:28 -0400 Subject: [PATCH 3/3] proper cookies keying --- httpbin/core.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/httpbin/core.py b/httpbin/core.py index ce7d1df..e01cf7f 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -183,17 +183,17 @@ def view_status_code(code): def view_cookies(): """Returns cookie data.""" - return request.cookies + return dict(cookies=request.cookies) @app.route('/cookies/set//') def set_cookie(name, value): """Sets a cookie and redirects to cookie list.""" - response = app.make_response(redirect('/cookies')) - response.set_cookie(key=name, value=value) + r = app.make_response(redirect('/cookies')) + r.set_cookie(key=name, value=value) - return response + return r if __name__ == '__main__':