Skip to content

Commit 7ef2785

Browse files
Use 128 KB as default value for DEFAULT_BUFFER_SIZE (#926)
* Add `TlsInterception` acceptance test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Generate CA cert if not available * Fix lint and tests * Fix args * Remove acceptance tests for now Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 82be14e commit 7ef2785

File tree

7 files changed

+22
-21
lines changed

7 files changed

+22
-21
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ endif
2828

2929
.PHONY: all https-certificates sign-https-certificates ca-certificates
3030
.PHONY: lib-check lib-clean lib-test lib-package lib-coverage lib-lint lib-pytest
31-
.PHONY: lib-release-test lib-release lib-profile lib-doc
31+
.PHONY: lib-release-test lib-release lib-profile lib-doc lib-pre-commit
3232
.PHONY: lib-dep lib-flake8 lib-mypy lib-speedscope container-buildx-all-platforms
3333
.PHONY: container container-run container-release container-build container-buildx
3434
.PHONY: devtools dashboard dashboard-clean container-without-openssl
@@ -91,6 +91,9 @@ lib-clean:
9191
rm -rf proxy.py.egg-info
9292
rm -rf .pytest_cache
9393
rm -rf .hypothesis
94+
# Doc RST files are cached and can cause issues
95+
# See https://github.com/abhinavsingh/proxy.py/issues/642#issuecomment-1003444578
96+
rm docs/pkg/*.rst
9497

9598
lib-dep:
9699
pip install --upgrade pip && \
@@ -101,6 +104,9 @@ lib-dep:
101104
-r requirements-tunnel.txt && \
102105
pip install "setuptools>=42"
103106

107+
lib-pre-commit:
108+
python -m pre_commit run --hook-stage manual --all-files -v
109+
104110
lib-lint:
105111
python -m tox -e lint
106112

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,7 @@ usage: -m [-h] [--enable-events] [--enable-conn-pool] [--threadless]
22322232
[--filtered-url-regex-config FILTERED_URL_REGEX_CONFIG]
22332233
[--cloudflare-dns-mode CLOUDFLARE_DNS_MODE]
22342234

2235-
proxy.py v2.4.0rc5.dev26+gb2b1bdc.d20211230
2235+
proxy.py v2.4.0rc5.dev31+gc998255
22362236

22372237
options:
22382238
-h, --help show this help message and exit
@@ -2290,21 +2290,17 @@ options:
22902290
Default: False. If used, will enable proxy protocol.
22912291
Only version 1 is currently supported.
22922292
--client-recvbuf-size CLIENT_RECVBUF_SIZE
2293-
Default: 1 MB. Maximum amount of data received from
2294-
the client in a single recv() operation. Bump this
2295-
value for faster uploads at the expense of increased
2296-
RAM.
2293+
Default: 128 KB. Maximum amount of data received from
2294+
the client in a single recv() operation.
22972295
--key-file KEY_FILE Default: None. Server key file to enable end-to-end
22982296
TLS encryption with clients. If used, must also pass
22992297
--cert-file.
23002298
--timeout TIMEOUT Default: 10.0. Number of seconds after which an
23012299
inactive connection must be dropped. Inactivity is
23022300
defined by no data sent or received by the client.
23032301
--server-recvbuf-size SERVER_RECVBUF_SIZE
2304-
Default: 1 MB. Maximum amount of data received from
2305-
the server in a single recv() operation. Bump this
2306-
value for faster downloads at the expense of increased
2307-
RAM.
2302+
Default: 128 KB. Maximum amount of data received from
2303+
the server in a single recv() operation.
23082304
--disable-http-proxy Default: False. Whether to disable
23092305
proxy.HttpProxyPlugin.
23102306
--disable-headers DISABLE_HEADERS

proxy/common/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _env_threadless_compliant() -> bool:
7474
# Defaults
7575
DEFAULT_BACKLOG = 100
7676
DEFAULT_BASIC_AUTH = None
77-
DEFAULT_BUFFER_SIZE = 1024 * 1024
77+
DEFAULT_BUFFER_SIZE = 128 * 1024
7878
DEFAULT_CA_CERT_DIR = None
7979
DEFAULT_CA_CERT_FILE = None
8080
DEFAULT_CA_KEY_FILE = None

proxy/http/handler.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@
3939
'--client-recvbuf-size',
4040
type=int,
4141
default=DEFAULT_CLIENT_RECVBUF_SIZE,
42-
help='Default: 1 MB. Maximum amount of data received from the '
43-
'client in a single recv() operation. Bump this '
44-
'value for faster uploads at the expense of '
45-
'increased RAM.',
42+
help='Default: ' + str(int(DEFAULT_CLIENT_RECVBUF_SIZE / 1024)) +
43+
' KB. Maximum amount of data received from the '
44+
'client in a single recv() operation.',
4645
)
4746
flags.add_argument(
4847
'--key-file',

proxy/http/proxy/server.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@
5656
'--server-recvbuf-size',
5757
type=int,
5858
default=DEFAULT_SERVER_RECVBUF_SIZE,
59-
help='Default: 1 MB. Maximum amount of data received from the '
60-
'server in a single recv() operation. Bump this '
61-
'value for faster downloads at the expense of '
62-
'increased RAM.',
59+
help='Default: ' + str(int(DEFAULT_SERVER_RECVBUF_SIZE / 1024)) +
60+
' KB. Maximum amount of data received from the '
61+
'server in a single recv() operation.',
6362
)
6463

6564
flags.add_argument(

requirements-testing.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ httpx==0.20.0
2020
h2==4.1.0
2121
hpack==4.0.0
2222
hyperframe==6.0.1
23+
pre-commit==2.16.0

tests/integration/test_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def proxy_py_subprocess(request: Any) -> Generator[int, None, None]:
6969
reason='OSError: [WinError 193] %1 is not a valid Win32 application',
7070
raises=OSError,
7171
) # type: ignore[misc]
72-
def test_curl(proxy_py_subprocess: int) -> None:
73-
"""An acceptance test with using ``curl`` through proxy.py."""
72+
def test_integration(proxy_py_subprocess: int) -> None:
73+
"""An acceptance test using ``curl`` through proxy.py."""
7474
this_test_module = Path(__file__)
7575
shell_script_test = this_test_module.with_suffix('.sh')
7676
check_output([str(shell_script_test), str(proxy_py_subprocess)])

0 commit comments

Comments
 (0)