impit 0.2.2__tar.gz → 0.2.3__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.
Files changed (40) hide show
  1. {impit-0.2.2 → impit-0.2.3}/Cargo.lock +23 -13
  2. {impit-0.2.2 → impit-0.2.3}/PKG-INFO +1 -1
  3. {impit-0.2.2 → impit-0.2.3}/impit-python/python/impit/impit.pyi +13 -0
  4. {impit-0.2.2 → impit-0.2.3}/impit-python/src/async_client.rs +17 -0
  5. {impit-0.2.2 → impit-0.2.3}/impit-python/src/client.rs +12 -0
  6. {impit-0.2.2 → impit-0.2.3}/impit-python/test/async_test.py +6 -0
  7. {impit-0.2.2 → impit-0.2.3}/impit-python/test/basic_test.py +5 -0
  8. {impit-0.2.2 → impit-0.2.3}/impit-python/uv.lock +1 -1
  9. {impit-0.2.2 → impit-0.2.3}/pyproject.toml +1 -1
  10. {impit-0.2.2 → impit-0.2.3}/python/impit/impit.pyi +13 -0
  11. {impit-0.2.2 → impit-0.2.3}/Cargo.toml +0 -0
  12. {impit-0.2.2 → impit-0.2.3}/README.md +0 -0
  13. {impit-0.2.2 → impit-0.2.3}/impit/Cargo.toml +0 -0
  14. {impit-0.2.2 → impit-0.2.3}/impit/README.md +0 -0
  15. {impit-0.2.2 → impit-0.2.3}/impit/docs/index.html +0 -0
  16. {impit-0.2.2 → impit-0.2.3}/impit/examples/basic.rs +0 -0
  17. {impit-0.2.2 → impit-0.2.3}/impit/src/errors.rs +0 -0
  18. {impit-0.2.2 → impit-0.2.3}/impit/src/http3.rs +0 -0
  19. {impit-0.2.2 → impit-0.2.3}/impit/src/http_headers/mod.rs +0 -0
  20. {impit-0.2.2 → impit-0.2.3}/impit/src/http_headers/statics.rs +0 -0
  21. {impit-0.2.2 → impit-0.2.3}/impit/src/impit.rs +0 -0
  22. {impit-0.2.2 → impit-0.2.3}/impit/src/lib.rs +0 -0
  23. {impit-0.2.2 → impit-0.2.3}/impit/src/request.rs +0 -0
  24. {impit-0.2.2 → impit-0.2.3}/impit/src/response_parsing/mod.rs +0 -0
  25. {impit-0.2.2 → impit-0.2.3}/impit/src/tls/ffdhe.rs +0 -0
  26. {impit-0.2.2 → impit-0.2.3}/impit/src/tls/mod.rs +0 -0
  27. {impit-0.2.2 → impit-0.2.3}/impit/src/tls/statics.rs +0 -0
  28. {impit-0.2.2 → impit-0.2.3}/impit-python/Cargo.toml +0 -0
  29. {impit-0.2.2 → impit-0.2.3}/impit-python/README.md +0 -0
  30. {impit-0.2.2 → impit-0.2.3}/impit-python/clippy.toml +0 -0
  31. {impit-0.2.2 → impit-0.2.3}/impit-python/python/impit/__init__.py +0 -0
  32. {impit-0.2.2 → impit-0.2.3}/impit-python/python/impit/py.typed +0 -0
  33. {impit-0.2.2 → impit-0.2.3}/impit-python/src/errors.rs +0 -0
  34. {impit-0.2.2 → impit-0.2.3}/impit-python/src/lib.rs +0 -0
  35. {impit-0.2.2 → impit-0.2.3}/impit-python/src/request.rs +0 -0
  36. {impit-0.2.2 → impit-0.2.3}/impit-python/src/response.rs +0 -0
  37. {impit-0.2.2 → impit-0.2.3}/impit-python/test/__init__.py +0 -0
  38. {impit-0.2.2 → impit-0.2.3}/impit-python/test/httpbin.py +0 -0
  39. {impit-0.2.2 → impit-0.2.3}/python/impit/__init__.py +0 -0
  40. {impit-0.2.2 → impit-0.2.3}/python/impit/py.typed +0 -0
@@ -323,9 +323,9 @@ dependencies = [
323
323
 
324
324
  [[package]]
325
325
  name = "backtrace"
326
- version = "0.3.74"
326
+ version = "0.3.75"
327
327
  source = "registry+https://github.com/rust-lang/crates.io-index"
328
- checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
328
+ checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
329
329
  dependencies = [
330
330
  "addr2line",
331
331
  "cfg-if",
@@ -1309,7 +1309,7 @@ dependencies = [
1309
1309
  "tokio",
1310
1310
  "tokio-rustls",
1311
1311
  "tower-service",
1312
- "webpki-roots",
1312
+ "webpki-roots 0.26.11",
1313
1313
  ]
1314
1314
 
1315
1315
  [[package]]
@@ -1503,7 +1503,7 @@ dependencies = [
1503
1503
  "thiserror",
1504
1504
  "tokio",
1505
1505
  "url",
1506
- "webpki-roots",
1506
+ "webpki-roots 0.26.11",
1507
1507
  ]
1508
1508
 
1509
1509
  [[package]]
@@ -2477,7 +2477,7 @@ dependencies = [
2477
2477
  "wasm-bindgen-futures",
2478
2478
  "wasm-streams",
2479
2479
  "web-sys",
2480
- "webpki-roots",
2480
+ "webpki-roots 0.26.11",
2481
2481
  "windows-registry",
2482
2482
  ]
2483
2483
 
@@ -2567,18 +2567,19 @@ dependencies = [
2567
2567
 
2568
2568
  [[package]]
2569
2569
  name = "rustls-pki-types"
2570
- version = "1.11.0"
2570
+ version = "1.12.0"
2571
2571
  source = "registry+https://github.com/rust-lang/crates.io-index"
2572
- checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c"
2572
+ checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79"
2573
2573
  dependencies = [
2574
2574
  "web-time",
2575
+ "zeroize",
2575
2576
  ]
2576
2577
 
2577
2578
  [[package]]
2578
2579
  name = "rustls-webpki"
2579
- version = "0.103.1"
2580
+ version = "0.103.2"
2580
2581
  source = "registry+https://github.com/rust-lang/crates.io-index"
2581
- checksum = "fef8b8769aaccf73098557a87cd1816b4f9c7c16811c9c77142aa695c16f2c03"
2582
+ checksum = "7149975849f1abb3832b246010ef62ccc80d3a76169517ada7188252b9cfb437"
2582
2583
  dependencies = [
2583
2584
  "aws-lc-rs",
2584
2585
  "ring",
@@ -2978,9 +2979,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
2978
2979
 
2979
2980
  [[package]]
2980
2981
  name = "tokio"
2981
- version = "1.44.2"
2982
+ version = "1.45.0"
2982
2983
  source = "registry+https://github.com/rust-lang/crates.io-index"
2983
- checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48"
2984
+ checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165"
2984
2985
  dependencies = [
2985
2986
  "backtrace",
2986
2987
  "bytes",
@@ -3326,9 +3327,18 @@ dependencies = [
3326
3327
 
3327
3328
  [[package]]
3328
3329
  name = "webpki-roots"
3329
- version = "0.26.10"
3330
+ version = "0.26.11"
3331
+ source = "registry+https://github.com/rust-lang/crates.io-index"
3332
+ checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9"
3333
+ dependencies = [
3334
+ "webpki-roots 1.0.0",
3335
+ ]
3336
+
3337
+ [[package]]
3338
+ name = "webpki-roots"
3339
+ version = "1.0.0"
3330
3340
  source = "registry+https://github.com/rust-lang/crates.io-index"
3331
- checksum = "37493cadf42a2a939ed404698ded7fb378bf301b5011f973361779a3a74f8c93"
3341
+ checksum = "2853738d1cc4f2da3a225c18ec6c3721abb31961096e9dbf5ab35fa88b19cfdb"
3332
3342
  dependencies = [
3333
3343
  "rustls-pki-types",
3334
3344
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: impit
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -96,6 +96,13 @@ class Response:
96
96
  class Client:
97
97
  """Synchronous HTTP client with browser impersonation capabilities."""
98
98
 
99
+ def __enter__(self) -> Client:
100
+ """Enter the runtime context related to this object."""
101
+
102
+ def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: object | None) -> None:
103
+ """Exit the runtime context related to this object."""
104
+
105
+
99
106
  def __init__(
100
107
  self,
101
108
  browser: Browser | None = None,
@@ -307,6 +314,12 @@ class Client:
307
314
 
308
315
  class AsyncClient:
309
316
  """Asynchronous HTTP client with browser impersonation capabilities."""
317
+
318
+ async def __aenter__(self) -> AsyncClient:
319
+ """Enter the runtime context related to this object."""
320
+
321
+ async def __aexit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: object | None) -> None:
322
+ """Exit the runtime context related to this object."""
310
323
 
311
324
  def __init__(
312
325
  self,
@@ -14,6 +14,23 @@ pub(crate) struct AsyncClient {
14
14
 
15
15
  #[pymethods]
16
16
  impl AsyncClient {
17
+ pub fn __aenter__(
18
+ slf: Py<Self>,
19
+ py: Python<'_>,
20
+ ) -> Result<pyo3::Bound<'_, pyo3::PyAny>, pyo3::PyErr> {
21
+ pyo3_async_runtimes::async_std::future_into_py::<_, Py<AsyncClient>>(py, async { Ok(slf) })
22
+ }
23
+
24
+ pub fn __aexit__<'python>(
25
+ &mut self,
26
+ _exc_type: &crate::Bound<'_, crate::PyAny>,
27
+ _exc_value: &crate::Bound<'_, crate::PyAny>,
28
+ _traceback: &crate::Bound<'_, crate::PyAny>,
29
+ py: Python<'python>,
30
+ ) -> Result<pyo3::Bound<'python, pyo3::PyAny>, pyo3::PyErr> {
31
+ pyo3_async_runtimes::async_std::future_into_py::<_, ()>(py, async { Ok(()) })
32
+ }
33
+
17
34
  #[new]
18
35
  #[pyo3(signature = (browser=None, http3=None, proxy=None, timeout=None, verify=None, default_encoding=None, follow_redirects=None, max_redirects=Some(20)))]
19
36
  pub fn new(
@@ -22,6 +22,18 @@ pub(crate) struct Client {
22
22
 
23
23
  #[pymethods]
24
24
  impl Client {
25
+ pub fn __enter__(slf: Py<Self>) -> Py<Self> {
26
+ slf
27
+ }
28
+
29
+ pub fn __exit__(
30
+ &mut self,
31
+ _exc_type: &crate::Bound<'_, crate::PyAny>,
32
+ _exc_value: &crate::Bound<'_, crate::PyAny>,
33
+ _traceback: &crate::Bound<'_, crate::PyAny>,
34
+ ) {
35
+ }
36
+
25
37
  #[new]
26
38
  #[pyo3(signature = (browser=None, http3=None, proxy=None, timeout=None, verify=None, default_encoding=None, follow_redirects=None, max_redirects=Some(20)))]
27
39
  pub fn new(
@@ -27,6 +27,12 @@ class TestBasicRequests:
27
27
  resp = await impit.get(f'{protocol}example.org')
28
28
  assert resp.status_code == 200
29
29
 
30
+ @pytest.mark.asyncio
31
+ async def test_context_manager(self, browser: Browser) -> None:
32
+ async with AsyncClient(browser=browser) as impit:
33
+ resp = await impit.get('https://example.org')
34
+ assert resp.status_code == 200
35
+
30
36
  @pytest.mark.asyncio
31
37
  async def test_boringssl_based_server(self, browser: Browser) -> None:
32
38
  impit = AsyncClient(browser=browser)
@@ -26,6 +26,11 @@ class TestBasicRequests:
26
26
  resp = impit.get(f'{protocol}example.org')
27
27
  assert resp.status_code == 200
28
28
 
29
+ def test_context_manager(self, browser: Browser) -> None:
30
+ with Client(browser=browser) as impit:
31
+ resp = impit.get('https://example.org')
32
+ assert resp.status_code == 200
33
+
29
34
  def test_boringssl_based_server(self, browser: Browser) -> None:
30
35
  impit = Client(browser=browser)
31
36
 
@@ -106,7 +106,7 @@ wheels = [
106
106
 
107
107
  [[package]]
108
108
  name = "impit"
109
- version = "0.2.1"
109
+ version = "0.2.2"
110
110
  source = { editable = "." }
111
111
 
112
112
  [package.dev-dependencies]
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "impit"
7
- version = "0.2.2"
7
+ version = "0.2.3"
8
8
  description = "A library for making HTTP requests through browser impersonation"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Jindřich Bär" }]
@@ -96,6 +96,13 @@ class Response:
96
96
  class Client:
97
97
  """Synchronous HTTP client with browser impersonation capabilities."""
98
98
 
99
+ def __enter__(self) -> Client:
100
+ """Enter the runtime context related to this object."""
101
+
102
+ def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: object | None) -> None:
103
+ """Exit the runtime context related to this object."""
104
+
105
+
99
106
  def __init__(
100
107
  self,
101
108
  browser: Browser | None = None,
@@ -307,6 +314,12 @@ class Client:
307
314
 
308
315
  class AsyncClient:
309
316
  """Asynchronous HTTP client with browser impersonation capabilities."""
317
+
318
+ async def __aenter__(self) -> AsyncClient:
319
+ """Enter the runtime context related to this object."""
320
+
321
+ async def __aexit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: object | None) -> None:
322
+ """Exit the runtime context related to this object."""
310
323
 
311
324
  def __init__(
312
325
  self,
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