Skip to content

Commit 93e1418

Browse files
authored
Merge branch 'master' into consolidate-version-string
2 parents 6374680 + ae48457 commit 93e1418

File tree

7 files changed

+326
-62
lines changed

7 files changed

+326
-62
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dockerfile

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ dist/
77
.tox
88
*.egg-info
99
*.swp
10+
.vscode/

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
FROM ubuntu:18.04
22

3+
LABEL name="httpbin"
4+
LABEL version="0.9.0"
5+
LABEL description="A simple HTTP service."
6+
LABEL org.kennethreitz.vendor="Kenneth Reitz"
7+
38
RUN apt update -y && apt install python3-pip -y
49

510
EXPOSE 80

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
include httpbin/VERSION README.rst LICENSE AUTHORS requirements.txt test_httpbin.py
1+
include httpbin/VERSION README.md LICENSE AUTHORS test_httpbin.py
22
recursive-include httpbin/templates *
33
recursive-include httpbin/static *

httpbin/core.py

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def jsonify(*args, **kwargs):
5858

5959
app = Flask(__name__, template_folder=tmpl_dir)
6060
app.debug = bool(os.environ.get('DEBUG'))
61+
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True
6162

6263
app.add_template_global('HTTPBIN_TRACKING' in os.environ, name='tracking_enabled')
6364

@@ -86,8 +87,7 @@ def jsonify(*args, **kwargs):
8687
"host": "httpbin.org", # overrides localhost:5000
8788
"basePath": "/", # base bash for blueprint registration
8889
"schemes": [
89-
"https",
90-
"http"
90+
"https"
9191
],
9292
'protocol': 'https',
9393
'tags': [
@@ -513,17 +513,58 @@ def redirect_to():
513513
- Redirects
514514
produces:
515515
- text/html
516-
parameters:
517-
- name: url
518-
type: string
519-
- name: status_code
520-
type: int
516+
get:
517+
parameters:
518+
- in: query
519+
name: url
520+
type: string
521+
required: true
522+
- in: query
523+
name: status_code
524+
type: int
525+
post:
526+
consumes:
527+
- application/x-www-form-urlencoded
528+
parameters:
529+
- in: formData
530+
name: url
531+
type: string
532+
required: true
533+
- in: formData
534+
name: status_code
535+
type: int
536+
required: false
537+
patch:
538+
consumes:
539+
- application/x-www-form-urlencoded
540+
parameters:
541+
- in: formData
542+
name: url
543+
type: string
544+
required: true
545+
- in: formData
546+
name: status_code
547+
type: int
548+
required: false
549+
put:
550+
consumes:
551+
- application/x-www-form-urlencoded
552+
parameters:
553+
- in: formData
554+
name: url
555+
type: string
556+
required: true
557+
- in: formData
558+
name: status_code
559+
type: int
560+
required: false
521561
responses:
522562
302:
523563
description: A redirection.
524564
"""
525565

526-
args = CaseInsensitiveDict(request.args.items())
566+
argsDict = request.form.to_dict(flat=True) if request.method in ('POST', 'PATCH', 'PUT') else request.args.items()
567+
args = CaseInsensitiveDict(argsDict)
527568

528569
# We need to build the response manually and convert to UTF-8 to prevent
529570
# werkzeug from "fixing" the URL. This endpoint should set the Location
@@ -1075,7 +1116,7 @@ def digest_auth(qop=None, user='user', passwd='passwd', algorithm='MD5', stale_a
10751116
return response
10761117

10771118

1078-
@app.route('/delay/<delay>')
1119+
@app.route('/delay/<delay>', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'TRACE'])
10791120
def delay_response(delay):
10801121
""""Returns a delayed response (max of 10 seconds).
10811122
---
@@ -1105,6 +1146,31 @@ def drip():
11051146
---
11061147
tags:
11071148
- Dynamic data
1149+
parameters:
1150+
- in: query
1151+
name: duration
1152+
type: number
1153+
description: The amount of time (in seconds) over which to drip each byte
1154+
default: 2
1155+
required: false
1156+
- in: query
1157+
name: numbytes
1158+
type: integer
1159+
description: The number of bytes to respond with
1160+
default: 10
1161+
required: false
1162+
- in: query
1163+
name: code
1164+
type: integer
1165+
description: The response code that will be returned
1166+
default: 200
1167+
required: false
1168+
- in: query
1169+
name: delay
1170+
type: number
1171+
description: The amount of time (in seconds) to delay before responding
1172+
default: 2
1173+
required: false
11081174
produces:
11091175
- application/octet-stream
11101176
responses:
@@ -1127,7 +1193,7 @@ def drip():
11271193
pause = duration / numbytes
11281194
def generate_bytes():
11291195
for i in xrange(numbytes):
1130-
yield u"*".encode('utf-8')
1196+
yield b"*"
11311197
time.sleep(pause)
11321198

11331199
response = Response(generate_bytes(), headers={

0 commit comments

Comments
 (0)