httpbinx 1.3.0__tar.gz → 1.3.2__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {httpbinx-1.3.0/httpbinx.egg-info → httpbinx-1.3.2}/PKG-INFO +35 -3
- httpbinx-1.3.2/README.md +56 -0
- httpbinx-1.3.2/httpbinx/VERSION +1 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/dynamicdata.py +1 -1
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/redirects.py +2 -2
- {httpbinx-1.3.0 → httpbinx-1.3.2/httpbinx.egg-info}/PKG-INFO +35 -3
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx.egg-info/SOURCES.txt +9 -1
- httpbinx-1.3.2/tests/test_anything.py +17 -0
- httpbinx-1.3.2/tests/test_dynamic_data.py +70 -0
- httpbinx-1.3.2/tests/test_http_methods.py +38 -0
- httpbinx-1.3.2/tests/test_images.py +24 -0
- httpbinx-1.3.2/tests/test_redirects.py +21 -0
- httpbinx-1.3.2/tests/test_request_inspection.py +41 -0
- httpbinx-1.3.2/tests/test_response_formats.py +46 -0
- httpbinx-1.3.2/tests/test_status_codes.py +42 -0
- httpbinx-1.3.0/README.md +0 -24
- httpbinx-1.3.0/httpbinx/VERSION +0 -1
- {httpbinx-1.3.0 → httpbinx-1.3.2}/LICENSE +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/MANIFEST.in +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/__init__.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/constants.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/examples/__init__.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/helpers.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/main.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/__init__.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/anything.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/auth.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/cookies.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/httpmethods.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/images.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/inspection/__init__.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/inspection/request.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/inspection/response.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/responseformats.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/routers/statuscodes.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/schemas.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/static/UTF-8-demo.txt +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/static/favicon.png +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/static/images/httbinx_logo.png +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/static/images/httpbinx_cover.png +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/static/images/jackal.jpg +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/static/images/pig_icon.png +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/static/images/svg_logo.svg +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/static/images/wolf_1.webp +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/templates/index.html +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/templates/moby.html +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/templates/sample.xml +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/templates/trackingscripts.html +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx/utils.py +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx.egg-info/dependency_links.txt +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx.egg-info/requires.txt +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/httpbinx.egg-info/top_level.txt +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/setup.cfg +0 -0
- {httpbinx-1.3.0 → httpbinx-1.3.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: httpbinx
|
3
|
-
Version: 1.3.
|
3
|
+
Version: 1.3.2
|
4
4
|
Summary: HTTP Request & Response Service, written in Python + FastAPI.
|
5
5
|
Home-page: https://github.com/imleowoo/httpbinx
|
6
6
|
Author: Leo
|
@@ -21,9 +21,13 @@ Requires-Python: >=3.7
|
|
21
21
|
Description-Content-Type: text/markdown
|
22
22
|
License-File: LICENSE
|
23
23
|
|
24
|
-

|
24
|
+
](https://raw.githubusercontent.com/imleowoo/httpbinx/main/httpbinx/static/images/httpbinx_cover.png)
|
25
|
+
|
26
|
+
[](https://github.com/postmanlabs/httpbin)
|
27
|
+

|
25
28
|
|
26
29
|
# httpbinx
|
30
|
+
|
27
31
|
HTTP Request & Response Service, written in Python + FastAPI.
|
28
32
|
|
29
33
|
## Reference project
|
@@ -32,10 +36,28 @@ A [Kenneth Reitz](http://kennethreitz.org/bitcoin) Project. See https://github.
|
|
32
36
|
|
33
37
|
## Quick Start
|
34
38
|
|
39
|
+
## Installation
|
40
|
+
|
41
|
+
### PyPI
|
42
|
+
|
43
|
+
**[httpbinx](https://pypi.org/project/httpbinx/)** is available on PyPI
|
44
|
+
|
45
|
+
```shell
|
46
|
+
$ pip install httpbinx
|
47
|
+
```
|
48
|
+
|
49
|
+
### Source Code
|
50
|
+
|
51
|
+
```shell
|
52
|
+
$ git clone https://github.com/imleowoo/httpbinx.git
|
53
|
+
$ python setup.py install # or `pip install .`
|
54
|
+
```
|
55
|
+
|
56
|
+
## Run it
|
57
|
+
|
35
58
|
### Run directly
|
36
59
|
|
37
60
|
```shell
|
38
|
-
$ python setup.py install
|
39
61
|
$ uvicorn httpbinx:app --host=0.0.0.0 --port=80
|
40
62
|
```
|
41
63
|
|
@@ -45,3 +67,13 @@ $ uvicorn httpbinx:app --host=0.0.0.0 --port=80
|
|
45
67
|
$ docker pull leowoo/httpbinx:latest
|
46
68
|
$ docker run -p 80:80 --name httpbinx leowoo/httpbinx:latest
|
47
69
|
```
|
70
|
+
|
71
|
+
### It starts running
|
72
|
+
|
73
|
+
```text
|
74
|
+
INFO: Started server process [17044]
|
75
|
+
INFO: Waiting for application startup.
|
76
|
+
INFO: Application startup complete.
|
77
|
+
INFO: Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit)
|
78
|
+
...
|
79
|
+
```
|
httpbinx-1.3.2/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
](https://raw.githubusercontent.com/imleowoo/httpbinx/main/httpbinx/static/images/httpbinx_cover.png)
|
2
|
+
|
3
|
+
[](https://github.com/postmanlabs/httpbin)
|
4
|
+

|
5
|
+
|
6
|
+
# httpbinx
|
7
|
+
|
8
|
+
HTTP Request & Response Service, written in Python + FastAPI.
|
9
|
+
|
10
|
+
## Reference project
|
11
|
+
|
12
|
+
A [Kenneth Reitz](http://kennethreitz.org/bitcoin) Project. See https://github.com/postmanlabs/httpbin
|
13
|
+
|
14
|
+
## Quick Start
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
### PyPI
|
19
|
+
|
20
|
+
**[httpbinx](https://pypi.org/project/httpbinx/)** is available on PyPI
|
21
|
+
|
22
|
+
```shell
|
23
|
+
$ pip install httpbinx
|
24
|
+
```
|
25
|
+
|
26
|
+
### Source Code
|
27
|
+
|
28
|
+
```shell
|
29
|
+
$ git clone https://github.com/imleowoo/httpbinx.git
|
30
|
+
$ python setup.py install # or `pip install .`
|
31
|
+
```
|
32
|
+
|
33
|
+
## Run it
|
34
|
+
|
35
|
+
### Run directly
|
36
|
+
|
37
|
+
```shell
|
38
|
+
$ uvicorn httpbinx:app --host=0.0.0.0 --port=80
|
39
|
+
```
|
40
|
+
|
41
|
+
### Run with Docker
|
42
|
+
|
43
|
+
```shell
|
44
|
+
$ docker pull leowoo/httpbinx:latest
|
45
|
+
$ docker run -p 80:80 --name httpbinx leowoo/httpbinx:latest
|
46
|
+
```
|
47
|
+
|
48
|
+
### It starts running
|
49
|
+
|
50
|
+
```text
|
51
|
+
INFO: Started server process [17044]
|
52
|
+
INFO: Waiting for application startup.
|
53
|
+
INFO: Application startup complete.
|
54
|
+
INFO: Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit)
|
55
|
+
...
|
56
|
+
```
|
@@ -0,0 +1 @@
|
|
1
|
+
1.3.2
|
@@ -159,7 +159,7 @@ async def link_page(
|
|
159
159
|
body += f'{i} '
|
160
160
|
else:
|
161
161
|
body += link.format(
|
162
|
-
href=f'/
|
162
|
+
href=f'/links/{n}/{i}', # TODO how to use router.url_path_for?
|
163
163
|
text=i
|
164
164
|
)
|
165
165
|
return HTMLResponse(content=html.format(body=body))
|
@@ -91,10 +91,10 @@ async def relative_redirect_n_times(
|
|
91
91
|
):
|
92
92
|
resp = Response(status_code=status.HTTP_302_FOUND)
|
93
93
|
if n == 1:
|
94
|
-
resp.headers['Location'] = request.url_for('get')
|
94
|
+
resp.headers['Location'] = str(request.url_for('get'))
|
95
95
|
return resp
|
96
96
|
redirect_name = relative_redirect_n_times.__name__
|
97
|
-
resp.headers['Location'] = request.url_for(redirect_name, n=n - 1)
|
97
|
+
resp.headers['Location'] = str(request.url_for(redirect_name, n=n - 1))
|
98
98
|
return resp
|
99
99
|
|
100
100
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: httpbinx
|
3
|
-
Version: 1.3.
|
3
|
+
Version: 1.3.2
|
4
4
|
Summary: HTTP Request & Response Service, written in Python + FastAPI.
|
5
5
|
Home-page: https://github.com/imleowoo/httpbinx
|
6
6
|
Author: Leo
|
@@ -21,9 +21,13 @@ Requires-Python: >=3.7
|
|
21
21
|
Description-Content-Type: text/markdown
|
22
22
|
License-File: LICENSE
|
23
23
|
|
24
|
-

|
24
|
+
](https://raw.githubusercontent.com/imleowoo/httpbinx/main/httpbinx/static/images/httpbinx_cover.png)
|
25
|
+
|
26
|
+
[](https://github.com/postmanlabs/httpbin)
|
27
|
+

|
25
28
|
|
26
29
|
# httpbinx
|
30
|
+
|
27
31
|
HTTP Request & Response Service, written in Python + FastAPI.
|
28
32
|
|
29
33
|
## Reference project
|
@@ -32,10 +36,28 @@ A [Kenneth Reitz](http://kennethreitz.org/bitcoin) Project. See https://github.
|
|
32
36
|
|
33
37
|
## Quick Start
|
34
38
|
|
39
|
+
## Installation
|
40
|
+
|
41
|
+
### PyPI
|
42
|
+
|
43
|
+
**[httpbinx](https://pypi.org/project/httpbinx/)** is available on PyPI
|
44
|
+
|
45
|
+
```shell
|
46
|
+
$ pip install httpbinx
|
47
|
+
```
|
48
|
+
|
49
|
+
### Source Code
|
50
|
+
|
51
|
+
```shell
|
52
|
+
$ git clone https://github.com/imleowoo/httpbinx.git
|
53
|
+
$ python setup.py install # or `pip install .`
|
54
|
+
```
|
55
|
+
|
56
|
+
## Run it
|
57
|
+
|
35
58
|
### Run directly
|
36
59
|
|
37
60
|
```shell
|
38
|
-
$ python setup.py install
|
39
61
|
$ uvicorn httpbinx:app --host=0.0.0.0 --port=80
|
40
62
|
```
|
41
63
|
|
@@ -45,3 +67,13 @@ $ uvicorn httpbinx:app --host=0.0.0.0 --port=80
|
|
45
67
|
$ docker pull leowoo/httpbinx:latest
|
46
68
|
$ docker run -p 80:80 --name httpbinx leowoo/httpbinx:latest
|
47
69
|
```
|
70
|
+
|
71
|
+
### It starts running
|
72
|
+
|
73
|
+
```text
|
74
|
+
INFO: Started server process [17044]
|
75
|
+
INFO: Waiting for application startup.
|
76
|
+
INFO: Application startup complete.
|
77
|
+
INFO: Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit)
|
78
|
+
...
|
79
|
+
```
|
@@ -39,4 +39,12 @@ httpbinx/static/images/wolf_1.webp
|
|
39
39
|
httpbinx/templates/index.html
|
40
40
|
httpbinx/templates/moby.html
|
41
41
|
httpbinx/templates/sample.xml
|
42
|
-
httpbinx/templates/trackingscripts.html
|
42
|
+
httpbinx/templates/trackingscripts.html
|
43
|
+
tests/test_anything.py
|
44
|
+
tests/test_dynamic_data.py
|
45
|
+
tests/test_http_methods.py
|
46
|
+
tests/test_images.py
|
47
|
+
tests/test_redirects.py
|
48
|
+
tests/test_request_inspection.py
|
49
|
+
tests/test_response_formats.py
|
50
|
+
tests/test_status_codes.py
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
Tag: Anything
|
4
|
+
"""
|
5
|
+
from fastapi.testclient import TestClient
|
6
|
+
from starlette import status
|
7
|
+
|
8
|
+
from httpbinx import app
|
9
|
+
|
10
|
+
client = TestClient(app)
|
11
|
+
|
12
|
+
|
13
|
+
def test_anything():
|
14
|
+
for method in ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'TRACE']:
|
15
|
+
response = client.request(method=method, url='/anything')
|
16
|
+
assert response.status_code == status.HTTP_200_OK
|
17
|
+
assert response.json()['method'] == method
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
Tag: Dynamic Data
|
4
|
+
"""
|
5
|
+
from base64 import b64encode
|
6
|
+
import time
|
7
|
+
import uuid
|
8
|
+
|
9
|
+
from fastapi.testclient import TestClient
|
10
|
+
from starlette import status
|
11
|
+
|
12
|
+
from httpbinx import app
|
13
|
+
|
14
|
+
client = TestClient(app)
|
15
|
+
|
16
|
+
|
17
|
+
def test_base64():
|
18
|
+
quote = 'Hello, HTTPBINX!'
|
19
|
+
b64 = b64encode(quote.encode())
|
20
|
+
response = client.get(f'/base64/{b64.decode()}')
|
21
|
+
assert response.text == quote
|
22
|
+
|
23
|
+
|
24
|
+
def test_bytes():
|
25
|
+
n = 2 ** 10
|
26
|
+
response = client.get(f'/bytes/{n}')
|
27
|
+
size = 0
|
28
|
+
for con in response.iter_bytes():
|
29
|
+
size += len(con)
|
30
|
+
assert size == n
|
31
|
+
|
32
|
+
# Initialize the random number generator
|
33
|
+
seed = 1
|
34
|
+
response = client.get(f'/bytes/{n}?seed={seed}')
|
35
|
+
size = 0
|
36
|
+
for con in response.iter_bytes():
|
37
|
+
size += len(con)
|
38
|
+
assert size == n
|
39
|
+
|
40
|
+
# Retrieve large bytes.
|
41
|
+
n = 2 ** 10 * 1000
|
42
|
+
response = client.get(f'/bytes/{n}')
|
43
|
+
assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
|
44
|
+
|
45
|
+
|
46
|
+
def test_delay():
|
47
|
+
delay = 5
|
48
|
+
start = time.time()
|
49
|
+
response = client.get(f'/delay/{delay}')
|
50
|
+
assert response.status_code == status.HTTP_200_OK
|
51
|
+
assert time.time() - start > delay
|
52
|
+
|
53
|
+
|
54
|
+
def test_drip(): pass
|
55
|
+
|
56
|
+
|
57
|
+
def test_links(): pass
|
58
|
+
|
59
|
+
|
60
|
+
def test_range(): pass
|
61
|
+
|
62
|
+
|
63
|
+
def test_stream_bytes(): pass
|
64
|
+
|
65
|
+
|
66
|
+
def test_uuid():
|
67
|
+
response = client.get('/uuid')
|
68
|
+
assert response.status_code == status.HTTP_200_OK
|
69
|
+
string = response.json()['uuid']
|
70
|
+
uuid.UUID(string)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
Tag: HTTP Methods
|
4
|
+
"""
|
5
|
+
from datetime import datetime
|
6
|
+
|
7
|
+
from fastapi.testclient import TestClient
|
8
|
+
from starlette import status
|
9
|
+
|
10
|
+
from httpbinx import app
|
11
|
+
|
12
|
+
client = TestClient(app)
|
13
|
+
|
14
|
+
|
15
|
+
def test_get():
|
16
|
+
response = client.get('/get')
|
17
|
+
assert response.status_code == status.HTTP_200_OK
|
18
|
+
assert response.json()['origin'] == 'testclient'
|
19
|
+
|
20
|
+
|
21
|
+
def test_post():
|
22
|
+
data = {
|
23
|
+
'name': 'Albert Einstein',
|
24
|
+
'age': str(datetime.now().year - 1879)
|
25
|
+
}
|
26
|
+
# string or bytes
|
27
|
+
str_or_bytes = b'httpbinx'
|
28
|
+
response = client.post('/post', content=str_or_bytes)
|
29
|
+
target = str_or_bytes.decode() if isinstance(str_or_bytes, bytes) else str_or_bytes
|
30
|
+
assert response.json()['data'] == target
|
31
|
+
|
32
|
+
# application/x-www-form-urlencoded
|
33
|
+
response = client.post('/post', data=data.copy())
|
34
|
+
assert response.json()['form'] == data
|
35
|
+
|
36
|
+
# application/json
|
37
|
+
response = client.post('/post', json=data.copy())
|
38
|
+
assert response.json()['json'] == data
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
Tag: Images
|
4
|
+
"""
|
5
|
+
from fastapi.testclient import TestClient
|
6
|
+
|
7
|
+
from httpbinx import app
|
8
|
+
|
9
|
+
client = TestClient(app)
|
10
|
+
|
11
|
+
|
12
|
+
def test_image(): pass
|
13
|
+
|
14
|
+
|
15
|
+
def test_image_png(): pass
|
16
|
+
|
17
|
+
|
18
|
+
def test_image_jpeg(): pass
|
19
|
+
|
20
|
+
|
21
|
+
def test_image_webp(): pass
|
22
|
+
|
23
|
+
|
24
|
+
def test_image_svg(): pass
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
Tag: Redirects
|
4
|
+
"""
|
5
|
+
from fastapi.testclient import TestClient
|
6
|
+
|
7
|
+
from httpbinx import app
|
8
|
+
|
9
|
+
client = TestClient(app)
|
10
|
+
|
11
|
+
|
12
|
+
def test_absolute_redirect(): pass
|
13
|
+
|
14
|
+
|
15
|
+
def test_redirect_to(): pass
|
16
|
+
|
17
|
+
|
18
|
+
def test_redirect(): pass
|
19
|
+
|
20
|
+
|
21
|
+
def test_relative_redirect(): pass
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
Tag: Request Inspection
|
4
|
+
"""
|
5
|
+
from fastapi.testclient import TestClient
|
6
|
+
from starlette import status
|
7
|
+
|
8
|
+
from httpbinx import app
|
9
|
+
|
10
|
+
client = TestClient(app)
|
11
|
+
|
12
|
+
|
13
|
+
def test_headers():
|
14
|
+
response = client.get('/headers')
|
15
|
+
assert response.status_code == status.HTTP_200_OK
|
16
|
+
assert response.json()['headers']['user-agent'] == 'testclient'
|
17
|
+
|
18
|
+
|
19
|
+
def test_ip():
|
20
|
+
response = client.get('/ip')
|
21
|
+
assert response.status_code == status.HTTP_200_OK
|
22
|
+
assert response.json()['origin'] == 'testclient'
|
23
|
+
|
24
|
+
|
25
|
+
def test_user_agent():
|
26
|
+
response = client.get('/user-agent')
|
27
|
+
assert response.status_code == status.HTTP_200_OK
|
28
|
+
assert response.json()['user-agent'] == 'testclient'
|
29
|
+
|
30
|
+
ua_examples = [
|
31
|
+
'Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion',
|
32
|
+
'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
|
33
|
+
'Opera/9.60 (Windows NT 6.0; U; en) Presto/2.1.1',
|
34
|
+
'Mozilla/5.0 (compatible; Googlebot/2.1; +https://www.google.com/bot.html)',
|
35
|
+
'curl/7.64.1',
|
36
|
+
'PostmanRuntime/7.26.5'
|
37
|
+
]
|
38
|
+
for ua in ua_examples:
|
39
|
+
headers = {'User-Agent': ua}
|
40
|
+
response = client.get('/user-agent', headers=headers)
|
41
|
+
assert response.json()['user-agent'] == ua
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
Tag: Response Formats
|
4
|
+
"""
|
5
|
+
from fastapi.testclient import TestClient
|
6
|
+
from starlette import status
|
7
|
+
|
8
|
+
from httpbinx import app
|
9
|
+
|
10
|
+
client = TestClient(app)
|
11
|
+
|
12
|
+
|
13
|
+
def test_brotli():
|
14
|
+
response = client.get('/brotli')
|
15
|
+
assert response.status_code == status.HTTP_200_OK
|
16
|
+
assert response.headers['content-encoding'] == 'br'
|
17
|
+
|
18
|
+
|
19
|
+
def test_deflate():
|
20
|
+
response = client.get('/deflate')
|
21
|
+
assert response.status_code == status.HTTP_200_OK
|
22
|
+
assert response.headers['content-encoding'] == 'deflate'
|
23
|
+
|
24
|
+
|
25
|
+
def test_gzip():
|
26
|
+
response = client.get('/gzip')
|
27
|
+
assert response.status_code == status.HTTP_200_OK
|
28
|
+
assert response.headers['content-encoding'] == 'gzip'
|
29
|
+
|
30
|
+
|
31
|
+
def test_deny():
|
32
|
+
response = client.get('/deny')
|
33
|
+
assert response.status_code == status.HTTP_403_FORBIDDEN
|
34
|
+
assert "YOU SHOULDN'T BE HERE" in response.text
|
35
|
+
|
36
|
+
|
37
|
+
def test_encoding_utf8(): pass
|
38
|
+
|
39
|
+
|
40
|
+
def test_html(): pass
|
41
|
+
|
42
|
+
|
43
|
+
def test_robot(): pass
|
44
|
+
|
45
|
+
|
46
|
+
def test_xml(): pass
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
Tag: Status Codes
|
4
|
+
"""
|
5
|
+
from urllib import parse
|
6
|
+
|
7
|
+
from fastapi.testclient import TestClient
|
8
|
+
from starlette import status
|
9
|
+
|
10
|
+
from httpbinx import app
|
11
|
+
|
12
|
+
client = TestClient(app)
|
13
|
+
|
14
|
+
|
15
|
+
def test_status_codes():
|
16
|
+
# All HTTP Codes
|
17
|
+
for name in [c for c in dir(status) if c.startswith('HTTP')]:
|
18
|
+
target_code = getattr(status, name)
|
19
|
+
for method in ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'TRACE']:
|
20
|
+
response = client.request(method=method, url=f'/status/{target_code}')
|
21
|
+
assert response.status_code in [
|
22
|
+
target_code,
|
23
|
+
status.HTTP_200_OK,
|
24
|
+
status.HTTP_405_METHOD_NOT_ALLOWED
|
25
|
+
]
|
26
|
+
|
27
|
+
# Random HTTP Codes
|
28
|
+
code_weight = {
|
29
|
+
status.HTTP_200_OK: 2,
|
30
|
+
status.HTTP_302_FOUND: 1,
|
31
|
+
status.HTTP_400_BAD_REQUEST: 1
|
32
|
+
}
|
33
|
+
# like: `200:3,400:1`
|
34
|
+
weight_string = ','.join(f'{code}:{weight}' for code, weight in code_weight.items())
|
35
|
+
response = client.get(f'/status/{parse.quote(weight_string)}')
|
36
|
+
assert response.status_code in code_weight
|
37
|
+
|
38
|
+
# Invalid wight
|
39
|
+
invalid_weight_string = 'invalid_code_and_weight'
|
40
|
+
response = client.get(f'/status/{parse.quote(invalid_weight_string)}')
|
41
|
+
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
42
|
+
assert response.text == 'Invalid status code'
|
httpbinx-1.3.0/README.md
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-

|
2
|
-
|
3
|
-
# httpbinx
|
4
|
-
HTTP Request & Response Service, written in Python + FastAPI.
|
5
|
-
|
6
|
-
## Reference project
|
7
|
-
|
8
|
-
A [Kenneth Reitz](http://kennethreitz.org/bitcoin) Project. See https://github.com/postmanlabs/httpbin
|
9
|
-
|
10
|
-
## Quick Start
|
11
|
-
|
12
|
-
### Run directly
|
13
|
-
|
14
|
-
```shell
|
15
|
-
$ python setup.py install
|
16
|
-
$ uvicorn httpbinx:app --host=0.0.0.0 --port=80
|
17
|
-
```
|
18
|
-
|
19
|
-
### Run with Docker
|
20
|
-
|
21
|
-
```shell
|
22
|
-
$ docker pull leowoo/httpbinx:latest
|
23
|
-
$ docker run -p 80:80 --name httpbinx leowoo/httpbinx:latest
|
24
|
-
```
|
httpbinx-1.3.0/httpbinx/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.3.0
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|