httpperf 1.0rc2__tar.gz → 1.0rc4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {httpperf-1.0rc2/httpperf.egg-info → httpperf-1.0rc4}/PKG-INFO +3 -3
- {httpperf-1.0rc2 → httpperf-1.0rc4}/README.md +2 -2
- {httpperf-1.0rc2 → httpperf-1.0rc4}/httpperf/__init__.py +53 -26
- httpperf-1.0rc4/httpperf/version.py +1 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4/httpperf.egg-info}/PKG-INFO +3 -3
- {httpperf-1.0rc2 → httpperf-1.0rc4}/httpperf.egg-info/SOURCES.txt +2 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/ae/ae.c +1 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/httpperf.c +426 -68
- {httpperf-1.0rc2 → httpperf-1.0rc4}/tests/test_api.py +1 -1
- httpperf-1.0rc4/tests/test_cancel.py +138 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/tests/test_connections.py +26 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/tests/test_engine.py +5 -3
- {httpperf-1.0rc2 → httpperf-1.0rc4}/tests/test_http_versions.py +75 -1
- httpperf-1.0rc4/tests/test_limiter.py +239 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/tests/test_response.py +36 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/tests/test_tls.py +62 -8
- httpperf-1.0rc2/httpperf/version.py +0 -1
- {httpperf-1.0rc2 → httpperf-1.0rc4}/LICENSE +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/MANIFEST.in +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/NOTICE +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/httpperf.egg-info/dependency_links.txt +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/httpperf.egg-info/top_level.txt +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/pyproject.toml +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/setup.cfg +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/setup.py +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/ae/.clang-format +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/ae/ae.h +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/ae/ae_epoll.c +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/ae/ae_evport.c +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/ae/ae_kqueue.c +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/ae/ae_select.c +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/ae/atomicvar.h +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/ae/config.h +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/ae/zmalloc.c +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/src/ae/zmalloc.h +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/tests/test_cookie.py +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/tests/test_httpbin.py +0 -0
- {httpperf-1.0rc2 → httpperf-1.0rc4}/tests/test_leaks.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: httpperf
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.0rc4
|
|
4
4
|
Summary: An asyncio HTTP client for load testing, built on libcurl.
|
|
5
5
|
Author-email: Tony Simpson <agjasimpson@gmail.com>
|
|
6
6
|
Project-URL: Source, https://github.com/tonysimpson/httpperf
|
|
@@ -103,9 +103,9 @@ All arguments are keyword-only. A session can be created anywhere, even outside
|
|
|
103
103
|
| `max_host_connections` | `0` | Per-session cap on connections per host. Needs `connections="session"` or `"none"`. |
|
|
104
104
|
| `max_connections` | `0` | Per-session cap on connections in use. Needs `connections="session"` or `"none"`. |
|
|
105
105
|
| `cert` | `None` | `(certfile, keyfile)` paths for a client certificate, used by every request unless the request overrides it. |
|
|
106
|
-
| `timeout` | `None` | Seconds allowed for each request, from the start of the transfer to the last byte (each redirect hop separately). `None` or 0 means no limit.
|
|
106
|
+
| `timeout` | `None` | Seconds allowed for each request, from the start of the transfer to the last byte (each redirect hop separately). `None` or 0 means no limit. Cancelling the task (or `asyncio.wait_for`) also stops the transfer and frees its connection slot; on HTTP/1.1 that closes the connection, on HTTP/2 and HTTP/3 it resets only that stream. |
|
|
107
107
|
| `connect_timeout` | `None` | Seconds allowed to connect, TLS included. `None` means curl's default of 300 s. |
|
|
108
|
-
| `verify` | `False` | Server certificate checking. `False`: none, as most load tests want. `True`: check against the system
|
|
108
|
+
| `verify` | `False` | Server certificate checking. `False`: none, as most load tests want. `True`: check against the system CAs, from the first of: `SSL_CERT_FILE` and `SSL_CERT_DIR`, if set and present; libcurl's own default bundle, if present; Python's default bundle (`ssl.get_default_verify_paths()`); the usual system locations. A path: check against that CA bundle. Requests can override it. |
|
|
109
109
|
| `json_dumps` | `None` | Function that turns a `json=` argument into the request body (`str` or `bytes`). `None` means the engine's. |
|
|
110
110
|
| `json_loads` | `None` | Function that turns the response body (`bytes`) into the result of `json()`. `None` means the engine's. |
|
|
111
111
|
|
|
@@ -77,9 +77,9 @@ All arguments are keyword-only. A session can be created anywhere, even outside
|
|
|
77
77
|
| `max_host_connections` | `0` | Per-session cap on connections per host. Needs `connections="session"` or `"none"`. |
|
|
78
78
|
| `max_connections` | `0` | Per-session cap on connections in use. Needs `connections="session"` or `"none"`. |
|
|
79
79
|
| `cert` | `None` | `(certfile, keyfile)` paths for a client certificate, used by every request unless the request overrides it. |
|
|
80
|
-
| `timeout` | `None` | Seconds allowed for each request, from the start of the transfer to the last byte (each redirect hop separately). `None` or 0 means no limit.
|
|
80
|
+
| `timeout` | `None` | Seconds allowed for each request, from the start of the transfer to the last byte (each redirect hop separately). `None` or 0 means no limit. Cancelling the task (or `asyncio.wait_for`) also stops the transfer and frees its connection slot; on HTTP/1.1 that closes the connection, on HTTP/2 and HTTP/3 it resets only that stream. |
|
|
81
81
|
| `connect_timeout` | `None` | Seconds allowed to connect, TLS included. `None` means curl's default of 300 s. |
|
|
82
|
-
| `verify` | `False` | Server certificate checking. `False`: none, as most load tests want. `True`: check against the system
|
|
82
|
+
| `verify` | `False` | Server certificate checking. `False`: none, as most load tests want. `True`: check against the system CAs, from the first of: `SSL_CERT_FILE` and `SSL_CERT_DIR`, if set and present; libcurl's own default bundle, if present; Python's default bundle (`ssl.get_default_verify_paths()`); the usual system locations. A path: check against that CA bundle. Requests can override it. |
|
|
83
83
|
| `json_dumps` | `None` | Function that turns a `json=` argument into the request body (`str` or `bytes`). `None` means the engine's. |
|
|
84
84
|
| `json_loads` | `None` | Function that turns the response body (`bytes`) into the result of `json()`. `None` means the engine's. |
|
|
85
85
|
|
|
@@ -5,6 +5,7 @@ import email.utils
|
|
|
5
5
|
import http
|
|
6
6
|
import json as _json
|
|
7
7
|
import os
|
|
8
|
+
import ssl
|
|
8
9
|
import sys
|
|
9
10
|
import threading
|
|
10
11
|
import time
|
|
@@ -26,26 +27,33 @@ _CA_FILES = (
|
|
|
26
27
|
"/etc/ssl/certs/ca-certificates.crt",
|
|
27
28
|
"/etc/pki/tls/certs/ca-bundle.crt",
|
|
28
29
|
"/etc/ssl/ca-bundle.pem",
|
|
30
|
+
"/etc/pki/tls/cacert.pem",
|
|
29
31
|
"/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem",
|
|
30
32
|
"/etc/ssl/cert.pem",
|
|
31
33
|
)
|
|
32
34
|
|
|
33
35
|
|
|
34
|
-
def
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
def _find_ca():
|
|
37
|
+
paths = ssl.get_default_verify_paths()
|
|
38
|
+
ca_file = os.environ.get(paths.openssl_cafile_env)
|
|
39
|
+
ca_dir = os.environ.get(paths.openssl_capath_env)
|
|
40
|
+
ca_file = ca_file if ca_file and os.path.isfile(ca_file) else None
|
|
41
|
+
ca_dir = ca_dir if ca_dir and os.path.isdir(ca_dir) else None
|
|
42
|
+
if ca_file or ca_dir:
|
|
43
|
+
return ca_file, ca_dir
|
|
38
44
|
builtin = _httpperf.default_ca_file()
|
|
39
45
|
if builtin and os.path.exists(builtin):
|
|
40
|
-
return None
|
|
41
|
-
|
|
46
|
+
return None, None
|
|
47
|
+
if paths.cafile and os.path.isfile(paths.cafile):
|
|
48
|
+
return paths.cafile, None
|
|
49
|
+
return next((path for path in _CA_FILES if os.path.exists(path)), None), None
|
|
42
50
|
|
|
43
51
|
|
|
44
|
-
|
|
52
|
+
_ca = _find_ca()
|
|
45
53
|
|
|
46
54
|
|
|
47
55
|
def _verify(verify):
|
|
48
|
-
return
|
|
56
|
+
return _ca if verify is True and _ca != (None, None) else verify
|
|
49
57
|
|
|
50
58
|
|
|
51
59
|
class RequestError(Exception):
|
|
@@ -367,6 +375,9 @@ class Headers(collections.abc.Mapping):
|
|
|
367
375
|
return repr(dict(self.items()))
|
|
368
376
|
|
|
369
377
|
|
|
378
|
+
_UNSET = object()
|
|
379
|
+
|
|
380
|
+
|
|
370
381
|
class Response:
|
|
371
382
|
__slots__ = (
|
|
372
383
|
"_req",
|
|
@@ -391,6 +402,15 @@ class Response:
|
|
|
391
402
|
self._resp = resp
|
|
392
403
|
self._start_time = start_time
|
|
393
404
|
self._end_time = end_time
|
|
405
|
+
self._redirect_url = _UNSET
|
|
406
|
+
self._prev = None
|
|
407
|
+
self._body = None
|
|
408
|
+
self._text = None
|
|
409
|
+
self._header = None
|
|
410
|
+
self._headers_tuple = None
|
|
411
|
+
self._headers = None
|
|
412
|
+
self._encoding = None
|
|
413
|
+
self._json = _UNSET
|
|
394
414
|
|
|
395
415
|
@property
|
|
396
416
|
def request(self):
|
|
@@ -432,7 +452,7 @@ class Response:
|
|
|
432
452
|
|
|
433
453
|
@property
|
|
434
454
|
def redirect_url(self):
|
|
435
|
-
if
|
|
455
|
+
if self._redirect_url is _UNSET:
|
|
436
456
|
self._redirect_url = self._resp.get_redirect_url()
|
|
437
457
|
return self._redirect_url
|
|
438
458
|
|
|
@@ -509,55 +529,51 @@ class Response:
|
|
|
509
529
|
@property
|
|
510
530
|
def history(self):
|
|
511
531
|
result = []
|
|
512
|
-
cur =
|
|
532
|
+
cur = self._prev
|
|
513
533
|
while cur is not None:
|
|
514
534
|
result.append(cur)
|
|
515
|
-
cur =
|
|
535
|
+
cur = cur._prev
|
|
516
536
|
result.reverse()
|
|
517
537
|
return result
|
|
518
538
|
|
|
519
539
|
@property
|
|
520
540
|
def body(self):
|
|
521
|
-
if
|
|
541
|
+
if self._body is None:
|
|
522
542
|
self._body = self._resp.get_body()
|
|
523
543
|
return self._body
|
|
524
544
|
|
|
525
545
|
@property
|
|
526
546
|
def encoding(self):
|
|
527
|
-
if
|
|
547
|
+
if self._encoding is None:
|
|
528
548
|
self._encoding = _encoding_from_content_type(self.headers.get("content-type"))
|
|
529
549
|
return self._encoding
|
|
530
550
|
|
|
531
551
|
@encoding.setter
|
|
532
552
|
def encoding(self, encoding):
|
|
533
553
|
self._encoding = encoding
|
|
534
|
-
|
|
535
|
-
del self._text
|
|
554
|
+
self._text = None
|
|
536
555
|
|
|
537
556
|
@property
|
|
538
557
|
def text(self):
|
|
539
|
-
if
|
|
558
|
+
if self._text is None:
|
|
540
559
|
self._text = self.body.decode(self.encoding)
|
|
541
560
|
return self._text
|
|
542
561
|
|
|
543
562
|
def json(self):
|
|
544
|
-
if
|
|
563
|
+
if self._json is _UNSET:
|
|
545
564
|
self._json = self._json_loads(self.body)
|
|
546
565
|
return self._json
|
|
547
566
|
|
|
548
567
|
@property
|
|
549
568
|
def headers(self):
|
|
550
|
-
if
|
|
569
|
+
if self._headers is None:
|
|
551
570
|
self._headers = Headers(self.headers_tuple)
|
|
552
571
|
return self._headers
|
|
553
572
|
|
|
554
573
|
@property
|
|
555
574
|
def headers_tuple(self):
|
|
556
|
-
if
|
|
557
|
-
|
|
558
|
-
self._headers_tuple = tuple(
|
|
559
|
-
[(name, value.strip()) for name, _, value in [line.partition(":") for line in block.split("\r\n")[1:]]]
|
|
560
|
-
)
|
|
575
|
+
if self._headers_tuple is None:
|
|
576
|
+
self._headers_tuple = _httpperf.parse_headers(self._resp.get_header())
|
|
561
577
|
return self._headers_tuple
|
|
562
578
|
|
|
563
579
|
def _final_header_block(self):
|
|
@@ -566,11 +582,21 @@ class Response:
|
|
|
566
582
|
|
|
567
583
|
@property
|
|
568
584
|
def header(self):
|
|
569
|
-
if
|
|
585
|
+
if self._header is None:
|
|
570
586
|
self._header = self._resp.get_header().decode("latin-1")
|
|
571
587
|
return self._header
|
|
572
588
|
|
|
573
589
|
|
|
590
|
+
class _Future(asyncio.Future):
|
|
591
|
+
__slots__ = ("_session", "_handle")
|
|
592
|
+
|
|
593
|
+
def cancel(self, *args):
|
|
594
|
+
if not super().cancel(*args):
|
|
595
|
+
return False
|
|
596
|
+
self._session.cancel(self._handle)
|
|
597
|
+
return True
|
|
598
|
+
|
|
599
|
+
|
|
574
600
|
class Session:
|
|
575
601
|
def __init__(
|
|
576
602
|
self,
|
|
@@ -747,8 +773,9 @@ class Session:
|
|
|
747
773
|
self._session.attach(engine._ae_loop)
|
|
748
774
|
if loop is not engine._loop():
|
|
749
775
|
engine._bind(loop)
|
|
750
|
-
future = loop
|
|
751
|
-
self._session
|
|
776
|
+
future = _Future(loop=loop)
|
|
777
|
+
future._session = self._session
|
|
778
|
+
future._handle = self._session.request(
|
|
752
779
|
future,
|
|
753
780
|
method,
|
|
754
781
|
url,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0rc4"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: httpperf
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.0rc4
|
|
4
4
|
Summary: An asyncio HTTP client for load testing, built on libcurl.
|
|
5
5
|
Author-email: Tony Simpson <agjasimpson@gmail.com>
|
|
6
6
|
Project-URL: Source, https://github.com/tonysimpson/httpperf
|
|
@@ -103,9 +103,9 @@ All arguments are keyword-only. A session can be created anywhere, even outside
|
|
|
103
103
|
| `max_host_connections` | `0` | Per-session cap on connections per host. Needs `connections="session"` or `"none"`. |
|
|
104
104
|
| `max_connections` | `0` | Per-session cap on connections in use. Needs `connections="session"` or `"none"`. |
|
|
105
105
|
| `cert` | `None` | `(certfile, keyfile)` paths for a client certificate, used by every request unless the request overrides it. |
|
|
106
|
-
| `timeout` | `None` | Seconds allowed for each request, from the start of the transfer to the last byte (each redirect hop separately). `None` or 0 means no limit.
|
|
106
|
+
| `timeout` | `None` | Seconds allowed for each request, from the start of the transfer to the last byte (each redirect hop separately). `None` or 0 means no limit. Cancelling the task (or `asyncio.wait_for`) also stops the transfer and frees its connection slot; on HTTP/1.1 that closes the connection, on HTTP/2 and HTTP/3 it resets only that stream. |
|
|
107
107
|
| `connect_timeout` | `None` | Seconds allowed to connect, TLS included. `None` means curl's default of 300 s. |
|
|
108
|
-
| `verify` | `False` | Server certificate checking. `False`: none, as most load tests want. `True`: check against the system
|
|
108
|
+
| `verify` | `False` | Server certificate checking. `False`: none, as most load tests want. `True`: check against the system CAs, from the first of: `SSL_CERT_FILE` and `SSL_CERT_DIR`, if set and present; libcurl's own default bundle, if present; Python's default bundle (`ssl.get_default_verify_paths()`); the usual system locations. A path: check against that CA bundle. Requests can override it. |
|
|
109
109
|
| `json_dumps` | `None` | Function that turns a `json=` argument into the request body (`str` or `bytes`). `None` means the engine's. |
|
|
110
110
|
| `json_loads` | `None` | Function that turns the response body (`bytes`) into the result of `json()`. `None` means the engine's. |
|
|
111
111
|
|
|
@@ -23,11 +23,13 @@ src/ae/config.h
|
|
|
23
23
|
src/ae/zmalloc.c
|
|
24
24
|
src/ae/zmalloc.h
|
|
25
25
|
tests/test_api.py
|
|
26
|
+
tests/test_cancel.py
|
|
26
27
|
tests/test_connections.py
|
|
27
28
|
tests/test_cookie.py
|
|
28
29
|
tests/test_engine.py
|
|
29
30
|
tests/test_http_versions.py
|
|
30
31
|
tests/test_httpbin.py
|
|
31
32
|
tests/test_leaks.py
|
|
33
|
+
tests/test_limiter.py
|
|
32
34
|
tests/test_response.py
|
|
33
35
|
tests/test_tls.py
|
|
@@ -426,6 +426,7 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags)
|
|
|
426
426
|
DEBUG_PRINT("fd=%d fe->mask=%d", fd, fe->mask);
|
|
427
427
|
rfired = 1;
|
|
428
428
|
fe->rfileProc(eventLoop,fd,fe->clientData,mask);
|
|
429
|
+
fe = &eventLoop->events[fd];
|
|
429
430
|
}
|
|
430
431
|
if (fe->mask & mask & AE_WRITABLE) {
|
|
431
432
|
if (!rfired || fe->wfileProc != fe->rfileProc)
|