dothttp-req 0.0.44a35__tar.gz → 0.0.44a37__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 (53) hide show
  1. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/PKG-INFO +124 -16
  2. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/README.md +118 -9
  3. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/__main__.py +15 -1
  4. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/http.tx +10 -0
  5. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/models/computed.py +2 -0
  6. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/models/parse_models.py +8 -1
  7. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/parse/__init__.py +12 -2
  8. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/parse/request_base.py +27 -4
  9. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/pyproject.toml +10 -9
  10. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/LICENSE.txt +0 -0
  11. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/__init__.py +0 -0
  12. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/__init__.py +0 -0
  13. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/__main__.py +0 -0
  14. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/agent.py +0 -0
  15. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/handlers/__init__.py +0 -0
  16. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/handlers/basic_handlers.py +0 -0
  17. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/handlers/fs_handlers.py +0 -0
  18. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/handlers/gohandler.py +0 -0
  19. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/handlers/har2httphandler.py +0 -0
  20. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/handlers/http2har.py +0 -0
  21. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/handlers/http2postman.py +0 -0
  22. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/handlers/postman2http.py +0 -0
  23. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/models/__init__.py +0 -0
  24. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/models/har.py +0 -0
  25. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/postman/__init__.py +0 -0
  26. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/postman2_1/__init__.py +0 -0
  27. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/server.py +0 -0
  28. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/server/utils.py +0 -0
  29. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/version/__init__.py +0 -0
  30. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dotextensions/version/__main__.py +0 -0
  31. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/__init__.py +0 -0
  32. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/__version__.py +0 -0
  33. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/auth/__init__.py +0 -0
  34. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/auth/azure_auth.py +0 -0
  35. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/exceptions.py +0 -0
  36. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/models/__init__.py +0 -0
  37. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/parse/dsl_jsonparser.py +0 -0
  38. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/parse/expression.py +0 -0
  39. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/postScript.js +0 -0
  40. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/property_schema.py +0 -0
  41. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/script/__init__.py +0 -0
  42. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/script/js3py.py +0 -0
  43. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/utils/__init__.py +0 -0
  44. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/utils/common.py +0 -0
  45. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/utils/constants.py +0 -0
  46. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/utils/curl_utils.py +0 -0
  47. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/utils/json_utils.py +0 -0
  48. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/utils/log_utils.py +0 -0
  49. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp/utils/property_util.py +0 -0
  50. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp_test/__init__.py +0 -0
  51. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp_test/__main__.py +0 -0
  52. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp_test/conftest.py +0 -0
  53. {dothttp_req-0.0.44a35 → dothttp_req-0.0.44a37}/dothttp_test/dothttp_test.py +0 -0
@@ -1,26 +1,24 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dothttp-req
3
- Version: 0.0.44a35
3
+ Version: 0.0.44a37
4
4
  Summary: Dothttp is Simple http client for testing and development
5
5
  License: MIT
6
6
  License-File: LICENSE.txt
7
7
  Author: Prasanth
8
8
  Author-email: kesavarapu.siva@gmail.com
9
- Requires-Python: >=3.10,<3.15
9
+ Requires-Python: >=3.12,<3.15
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Operating System :: OS Independent
12
12
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.10
14
- Classifier: Programming Language :: Python :: 3.11
15
13
  Classifier: Programming Language :: Python :: 3.12
16
14
  Classifier: Programming Language :: Python :: 3.13
17
15
  Classifier: Programming Language :: Python :: 3.14
18
- Requires-Dist: cryptography (==50.0.0)
16
+ Requires-Dist: cryptography (==50.0.1)
19
17
  Requires-Dist: faker (==40.21.0)
20
18
  Requires-Dist: idna (==3.18)
21
19
  Requires-Dist: jsonschema (==4.26.0)
22
20
  Requires-Dist: jstyleson (==0.0.2)
23
- Requires-Dist: msal (==1.37.0)
21
+ Requires-Dist: msal (==1.38.0)
24
22
  Requires-Dist: parsys-requests-unixsocket (==0.3.2)
25
23
  Requires-Dist: pyyaml (==6.0.3)
26
24
  Requires-Dist: requests (==2.34.2)
@@ -28,9 +26,10 @@ Requires-Dist: requests-aws4auth (==1.3.2)
28
26
  Requires-Dist: requests-hawk (==1.2.1)
29
27
  Requires-Dist: requests-ntlm (==1.3.0)
30
28
  Requires-Dist: requests-pkcs12 (==1.27)
31
- Requires-Dist: restrictedpython (==8.2)
29
+ Requires-Dist: restrictedpython (==8.5)
32
30
  Requires-Dist: textx (==4.2.3)
33
31
  Requires-Dist: toml (==0.10.2)
32
+ Requires-Dist: truststore (==0.10.4)
34
33
  Requires-Dist: urllib3 (==2.7.0)
35
34
  Requires-Dist: xmltodict (>=1.0.2,<2.0.0)
36
35
  Project-URL: Bug Tracker, https://github.com/cedric05/dothttp
@@ -355,13 +354,15 @@ via [dothttp-code](https://marketplace.visualstudio.com/items?itemName=ShivaPras
355
354
  ### Command line options
356
355
 
357
356
  ```
358
- usage: dothttp [-h] [--curl] [--property-file PROPERTY_FILE] [--no-cookie] [--env ENV [ENV ...]] [--debug] [--info] [--format] [--stdout]
359
- [--property PROPERTY [PROPERTY ...]]
360
- file
357
+ usage: dothttp [-h] [--curl] [--property-file PROPERTY_FILE] [--no-cookie]
358
+ [--env ENV [ENV ...]] [--debug] [--info] [--format]
359
+ [--experimental] [--stdout]
360
+ [--property PROPERTY [PROPERTY ...]] [--target TARGET]
361
+ [file]
361
362
 
362
363
  http requests for humans
363
364
 
364
- optional arguments:
365
+ options:
365
366
  -h, --help show this help message and exit
366
367
 
367
368
  general:
@@ -369,23 +370,130 @@ general:
369
370
  --no-cookie, -nc cookie storage is disabled
370
371
  --debug, -d debug will enable logs and exceptions
371
372
  --info, -i more information
372
- file http file
373
+ file http file. use `-` or omit to read http content from
374
+ stdin
375
+ --target, -t TARGET targets a particular http definition
373
376
 
374
377
  property:
375
- --property-file PROPERTY_FILE, -p PROPERTY_FILE
378
+ --property-file, -p PROPERTY_FILE
376
379
  property file
377
- --env ENV [ENV ...], -e ENV [ENV ...]
378
- environment to select in property file. properties will be enabled on FIFO
380
+ --env, -e ENV [ENV ...]
381
+ environment to select in property file. properties
382
+ will be enabled on FIFO
383
+ --experimental, --b enable experimental
379
384
  --property PROPERTY [PROPERTY ...]
380
385
  list of property's
381
386
 
382
387
  format:
383
- --format, -fmt formatter
388
+ --format, -fmt format http file
384
389
  --stdout print to commandline
385
390
  ```
386
391
 
387
392
  checkout [examples]('./examples/dothttpazure.http')
388
393
 
394
+ -----------
395
+
396
+ ## Using dothttp with AI agents / coding assistants
397
+
398
+ **dothttp** is stdin/stdout friendly, so an AI agent (Claude Code, Cursor, a
399
+ custom LLM tool, a CI script, etc.) can fire a request without ever writing a
400
+ `.http` file to disk or leaving temp files behind.
401
+
402
+ Pipe the `.http` content on stdin using `-` as the file argument (or just
403
+ omit the file argument altogether):
404
+
405
+ ```shell
406
+ echo 'GET "https://httpbin.org/get"' | dothttp -
407
+ # or, equivalently
408
+ echo 'GET "https://httpbin.org/get"' | dothttp
409
+ ```
410
+
411
+ The response body is written to stdout, exactly like the file-based flow —
412
+ no extra banners or separators clutter the output unless a test script
413
+ (see [Templating](#templating)) actually produces something to report.
414
+
415
+ This composes with the regular flags, so an agent can still target a
416
+ specific request, substitute properties, or ask for a curl script instead
417
+ of executing the request:
418
+
419
+ ```shell
420
+ # multiple requests in one payload, run the 2nd one
421
+ # a heredoc is the easiest way to hand over multi-line content
422
+ dothttp - --target 2 <<EOF
423
+ GET "https://httpbin.org/get"
424
+
425
+ POST "https://httpbin.org/post"
426
+ EOF
427
+
428
+ # substitute a property from the command line
429
+ echo 'GET "https://httpbin.org/get?key={{myprop}}"' \
430
+ | dothttp - --property myprop=myvalue
431
+
432
+ # get a shareable curl command instead of executing the request
433
+ echo 'GET "https://httpbin.org/get"' | dothttp - --curl
434
+ ```
435
+
436
+ Property-file auto-discovery (`.dothttp.json`/`.yaml`/`.yml`/`.toml` in the
437
+ current directory) still works in stdin mode, since it's resolved relative
438
+ to the working directory the command is run from — handy for agents that
439
+ run from within a project checkout.
440
+
441
+ An explicit `>> "path/to/file"` output directive inside the piped content
442
+ still writes to that file instead of stdout, same as file-based input.
443
+
444
+ #### Reusing existing request definitions (`import` + `@name(...) : base`)
445
+
446
+ An agent working inside a project usually doesn't need to reinvent auth,
447
+ headers, or retry/timeout settings for every new request — a project's
448
+ existing `.http` files already define them. **dothttp** supports `import`
449
+ and named request inheritance (`@name("child") : "base"`), so an agent's
450
+ stdin snippet can just import the file with the shared setup and extend it,
451
+ inheriting everything from the base and overriding only what's different
452
+ (the path, method, payload, etc).
453
+
454
+ For example, [`examples/inheritance_example.http`](./examples/inheritance_example.http)
455
+ already defines an `"api base"` request with a host, `Authorization` header,
456
+ `timeout`, and `retry` configured. An agent can reuse all of it with a
457
+ two-line snippet:
458
+
459
+ ```shell
460
+ dothttp - --target "get repo" <<'EOF'
461
+ import "examples/inheritance_example.http";
462
+
463
+ @name("get repo") : "api base"
464
+ GET /repos/cedric05/dothttp
465
+ EOF
466
+ ```
467
+
468
+ This resolves to `GET https://api.github.com/repos/cedric05/dothttp` with
469
+ the `Authorization`, `timeout`, and `retry` settings from `"api base"`
470
+ applied automatically — the agent never had to know or copy those details.
471
+ `import` paths (like `--property-file` auto-discovery above) are resolved
472
+ relative to the working directory the command is run from, so this works
473
+ best when the agent runs from the project root.
474
+
475
+ #### Custom and system trusted CAs
476
+
477
+ Client certificates and trusted server CAs are configured separately. Use
478
+ `trust(...)` to provide one CA certificate bundle for server verification:
479
+
480
+ ```http
481
+ @name("internal api")
482
+ GET https://api.example.com
483
+ trust("/path/to/internal-root-ca.pem")
484
+ ```
485
+
486
+ Trusted CA settings are inherited by child requests, as shown in
487
+ [`examples/trust_store.http`](./examples/trust_store.http). Requests fail
488
+ normally when the server is not trusted; `@insecure` is still the explicit
489
+ way to disable certificate verification.
490
+
491
+ ```http
492
+ @name("system trust store")
493
+ @enable_trust_store
494
+ GET https://api.example.com
495
+ ```
496
+
389
497
  -----------
390
498
  ### Vscode alternatives
391
499
 
@@ -317,13 +317,15 @@ via [dothttp-code](https://marketplace.visualstudio.com/items?itemName=ShivaPras
317
317
  ### Command line options
318
318
 
319
319
  ```
320
- usage: dothttp [-h] [--curl] [--property-file PROPERTY_FILE] [--no-cookie] [--env ENV [ENV ...]] [--debug] [--info] [--format] [--stdout]
321
- [--property PROPERTY [PROPERTY ...]]
322
- file
320
+ usage: dothttp [-h] [--curl] [--property-file PROPERTY_FILE] [--no-cookie]
321
+ [--env ENV [ENV ...]] [--debug] [--info] [--format]
322
+ [--experimental] [--stdout]
323
+ [--property PROPERTY [PROPERTY ...]] [--target TARGET]
324
+ [file]
323
325
 
324
326
  http requests for humans
325
327
 
326
- optional arguments:
328
+ options:
327
329
  -h, --help show this help message and exit
328
330
 
329
331
  general:
@@ -331,23 +333,130 @@ general:
331
333
  --no-cookie, -nc cookie storage is disabled
332
334
  --debug, -d debug will enable logs and exceptions
333
335
  --info, -i more information
334
- file http file
336
+ file http file. use `-` or omit to read http content from
337
+ stdin
338
+ --target, -t TARGET targets a particular http definition
335
339
 
336
340
  property:
337
- --property-file PROPERTY_FILE, -p PROPERTY_FILE
341
+ --property-file, -p PROPERTY_FILE
338
342
  property file
339
- --env ENV [ENV ...], -e ENV [ENV ...]
340
- environment to select in property file. properties will be enabled on FIFO
343
+ --env, -e ENV [ENV ...]
344
+ environment to select in property file. properties
345
+ will be enabled on FIFO
346
+ --experimental, --b enable experimental
341
347
  --property PROPERTY [PROPERTY ...]
342
348
  list of property's
343
349
 
344
350
  format:
345
- --format, -fmt formatter
351
+ --format, -fmt format http file
346
352
  --stdout print to commandline
347
353
  ```
348
354
 
349
355
  checkout [examples]('./examples/dothttpazure.http')
350
356
 
357
+ -----------
358
+
359
+ ## Using dothttp with AI agents / coding assistants
360
+
361
+ **dothttp** is stdin/stdout friendly, so an AI agent (Claude Code, Cursor, a
362
+ custom LLM tool, a CI script, etc.) can fire a request without ever writing a
363
+ `.http` file to disk or leaving temp files behind.
364
+
365
+ Pipe the `.http` content on stdin using `-` as the file argument (or just
366
+ omit the file argument altogether):
367
+
368
+ ```shell
369
+ echo 'GET "https://httpbin.org/get"' | dothttp -
370
+ # or, equivalently
371
+ echo 'GET "https://httpbin.org/get"' | dothttp
372
+ ```
373
+
374
+ The response body is written to stdout, exactly like the file-based flow —
375
+ no extra banners or separators clutter the output unless a test script
376
+ (see [Templating](#templating)) actually produces something to report.
377
+
378
+ This composes with the regular flags, so an agent can still target a
379
+ specific request, substitute properties, or ask for a curl script instead
380
+ of executing the request:
381
+
382
+ ```shell
383
+ # multiple requests in one payload, run the 2nd one
384
+ # a heredoc is the easiest way to hand over multi-line content
385
+ dothttp - --target 2 <<EOF
386
+ GET "https://httpbin.org/get"
387
+
388
+ POST "https://httpbin.org/post"
389
+ EOF
390
+
391
+ # substitute a property from the command line
392
+ echo 'GET "https://httpbin.org/get?key={{myprop}}"' \
393
+ | dothttp - --property myprop=myvalue
394
+
395
+ # get a shareable curl command instead of executing the request
396
+ echo 'GET "https://httpbin.org/get"' | dothttp - --curl
397
+ ```
398
+
399
+ Property-file auto-discovery (`.dothttp.json`/`.yaml`/`.yml`/`.toml` in the
400
+ current directory) still works in stdin mode, since it's resolved relative
401
+ to the working directory the command is run from — handy for agents that
402
+ run from within a project checkout.
403
+
404
+ An explicit `>> "path/to/file"` output directive inside the piped content
405
+ still writes to that file instead of stdout, same as file-based input.
406
+
407
+ #### Reusing existing request definitions (`import` + `@name(...) : base`)
408
+
409
+ An agent working inside a project usually doesn't need to reinvent auth,
410
+ headers, or retry/timeout settings for every new request — a project's
411
+ existing `.http` files already define them. **dothttp** supports `import`
412
+ and named request inheritance (`@name("child") : "base"`), so an agent's
413
+ stdin snippet can just import the file with the shared setup and extend it,
414
+ inheriting everything from the base and overriding only what's different
415
+ (the path, method, payload, etc).
416
+
417
+ For example, [`examples/inheritance_example.http`](./examples/inheritance_example.http)
418
+ already defines an `"api base"` request with a host, `Authorization` header,
419
+ `timeout`, and `retry` configured. An agent can reuse all of it with a
420
+ two-line snippet:
421
+
422
+ ```shell
423
+ dothttp - --target "get repo" <<'EOF'
424
+ import "examples/inheritance_example.http";
425
+
426
+ @name("get repo") : "api base"
427
+ GET /repos/cedric05/dothttp
428
+ EOF
429
+ ```
430
+
431
+ This resolves to `GET https://api.github.com/repos/cedric05/dothttp` with
432
+ the `Authorization`, `timeout`, and `retry` settings from `"api base"`
433
+ applied automatically — the agent never had to know or copy those details.
434
+ `import` paths (like `--property-file` auto-discovery above) are resolved
435
+ relative to the working directory the command is run from, so this works
436
+ best when the agent runs from the project root.
437
+
438
+ #### Custom and system trusted CAs
439
+
440
+ Client certificates and trusted server CAs are configured separately. Use
441
+ `trust(...)` to provide one CA certificate bundle for server verification:
442
+
443
+ ```http
444
+ @name("internal api")
445
+ GET https://api.example.com
446
+ trust("/path/to/internal-root-ca.pem")
447
+ ```
448
+
449
+ Trusted CA settings are inherited by child requests, as shown in
450
+ [`examples/trust_store.http`](./examples/trust_store.http). Requests fail
451
+ normally when the server is not trusted; `@insecure` is still the explicit
452
+ way to disable certificate verification.
453
+
454
+ ```http
455
+ @name("system trust store")
456
+ @enable_trust_store
457
+ GET https://api.example.com
458
+ ```
459
+
351
460
  -----------
352
461
  ### Vscode alternatives
353
462
 
@@ -1,5 +1,6 @@
1
1
  import argparse
2
2
  import logging
3
+ import os
3
4
  import sys
4
5
 
5
6
  from requests.exceptions import RequestException
@@ -96,7 +97,12 @@ def main():
96
97
  property_group.add_argument(
97
98
  "--property", help="list of property's", nargs="+", default=[]
98
99
  )
99
- general_group.add_argument("file", help="http file")
100
+ general_group.add_argument(
101
+ "file",
102
+ help="http file. use `-` or omit to read http content from stdin",
103
+ nargs="?",
104
+ default=None,
105
+ )
100
106
  general_group.add_argument(
101
107
  "--target", "-t", help="targets a particular http definition", type=str
102
108
  )
@@ -110,6 +116,13 @@ def main():
110
116
  # this can be done better by adding validation in add_argument.
111
117
  eprint(f"command line property: `{one_prop}` is invalid, expected prop=val")
112
118
  sys.exit(1)
119
+ content = None
120
+ if args.file is None or args.file == "-":
121
+ if args.file is None and sys.stdin.isatty():
122
+ parser.error("file is required (or pipe .http content via stdin)")
123
+ content = sys.stdin.read()
124
+ # gives load_content a cwd-based dirname for property-file/import resolution
125
+ args.file = os.path.join(os.getcwd(), "-")
113
126
  config = Config(
114
127
  curl=args.curl,
115
128
  property_file=args.property_file,
@@ -123,6 +136,7 @@ def main():
123
136
  format=args.format,
124
137
  stdout=args.stdout,
125
138
  experimental=args.experimental,
139
+ content=content,
126
140
  )
127
141
  apply(config)
128
142
 
@@ -29,6 +29,7 @@ HTTP:
29
29
  urlwrap=URL
30
30
  (authwrap=AUTHWRAP)?
31
31
  (certificate = CERTAUTH)?
32
+ (trust = TRUSTAUTH)?
32
33
  (timeout=TIMEOUT)?
33
34
  (retry=RETRY)?
34
35
  (proxy=PROXY)?
@@ -81,6 +82,10 @@ CERTAUTH:
81
82
  )
82
83
  ;
83
84
 
85
+ TRUSTAUTH:
86
+ ('trust' | 'trustroot' | 'trustedca') '(' root=DotString ')'
87
+ ;
88
+
84
89
  HAWKAUTH:
85
90
  'hawkauth' '(' id=DotString ',' key = DotString (',' algorithm=DotString)? ')'
86
91
  ;
@@ -159,6 +164,7 @@ EXTRA_ARG:
159
164
  clear=CLEAR_SESSION
160
165
  | insecure=INSECURE
161
166
  | no_parent_script=CLEAR_PARENT_SCRIPT
167
+ | enable_trust_store=ENABLE_TRUST_STORE
162
168
  ;
163
169
 
164
170
  NAMED_ARG:
@@ -178,6 +184,10 @@ INSECURE:
178
184
  "@insecure"
179
185
  ;
180
186
 
187
+ ENABLE_TRUST_STORE:
188
+ "@enable_trust_store"
189
+ ;
190
+
181
191
  METHODTYPE:
182
192
  "GET" | "POST" | "OPTIONS"
183
193
  | "DELETE" | "CONNECT" | "PUT"
@@ -81,8 +81,10 @@ class HttpDef:
81
81
  payload: Optional[Payload] = None
82
82
  certificate: Optional[List[str]] = None
83
83
  p12: Optional[List[str]] = None
84
+ trust_root: Optional[str] = None
84
85
  output: str = None
85
86
  allow_insecure = False
87
+ enable_trust_store = False
86
88
  session_clear = False
87
89
  no_parent_script = False
88
90
  test_script: str = ""
@@ -214,7 +214,7 @@ class TestScript:
214
214
 
215
215
  @dataclass
216
216
  class Certificate:
217
- cert: str
217
+ cert: Optional[str]
218
218
  key: Optional[str]
219
219
 
220
220
 
@@ -224,6 +224,11 @@ class P12Certificate:
224
224
  password: Optional[str] = None
225
225
 
226
226
 
227
+ @dataclass
228
+ class Trust:
229
+ root: str
230
+
231
+
227
232
  @dataclass
228
233
  class ExtraArg:
229
234
  # clears session after each
@@ -232,6 +237,7 @@ class ExtraArg:
232
237
  insecure: Optional[str] = ""
233
238
  # ignore parent script
234
239
  no_parent_script: Optional[str] = ""
240
+ enable_trust_store: Optional[str] = ""
235
241
 
236
242
 
237
243
  @dataclass
@@ -249,6 +255,7 @@ class Http:
249
255
  lines: Optional[List[Line]]
250
256
  payload: Optional[Payload]
251
257
  output: Optional[ToFile]
258
+ trust: Optional[Trust] = None
252
259
  timeout: Optional[Timeout] = None
253
260
  retry: Optional[Retry] = None
254
261
  proxy: Optional[Proxy] = None
@@ -44,6 +44,7 @@ from ..models.parse_models import (
44
44
  P12Certificate,
45
45
  ScriptType,
46
46
  TestScript,
47
+ Trust,
47
48
  )
48
49
  from ..property_schema import property_schema
49
50
  from ..script import ScriptExecutionPython
@@ -277,6 +278,9 @@ class BaseModelProcessor:
277
278
  return
278
279
 
279
280
  def load_content(self):
281
+ if self.args.content is not None:
282
+ self.original_content = self.content = self.args.content
283
+ return
280
284
  if not os.path.exists(self.file):
281
285
  raise HttpFileNotFoundException(file=self.file)
282
286
  with open(self.file, "r", encoding="utf-8") as f:
@@ -553,7 +557,7 @@ class HttpDefBase(BaseModelProcessor):
553
557
  "certificate"
554
558
  )
555
559
  if certificate:
556
- if certificate.cert:
560
+ if hasattr(certificate, "cert") and certificate.cert:
557
561
  self.httpdef.certificate = [
558
562
  self.get_updated_content(certificate.cert),
559
563
  (
@@ -562,12 +566,16 @@ class HttpDefBase(BaseModelProcessor):
562
566
  else None
563
567
  ),
564
568
  ]
565
- elif certificate.p12_file:
569
+ elif hasattr(certificate, "p12_file") and certificate.p12_file:
566
570
  self.httpdef.p12 = [
567
571
  self.get_updated_content(certificate.p12_file),
568
572
  self.get_updated_content(certificate.password),
569
573
  ]
570
574
 
575
+ trust = self.get_current_or_base("trust")
576
+ if trust:
577
+ self.httpdef.trust_root = self.get_updated_content(trust.root)
578
+
571
579
  def load_extra_flags(self):
572
580
  # flags are extendable
573
581
  # once its marked as allow insecure
@@ -583,6 +591,8 @@ class HttpDefBase(BaseModelProcessor):
583
591
  self.httpdef.session_clear = True
584
592
  elif flag.insecure:
585
593
  self.httpdef.allow_insecure = True
594
+ elif flag.enable_trust_store:
595
+ self.httpdef.enable_trust_store = True
586
596
 
587
597
  for current_flag in self.http.extra_args:
588
598
  if current_flag.no_parent_script:
@@ -309,6 +309,8 @@ class HttpFileFormatter(RequestBase):
309
309
  output_str += f"@clear{new_line}"
310
310
  if extra_arg.insecure:
311
311
  output_str += f"@insecure{new_line}"
312
+ if extra_arg.enable_trust_store:
313
+ output_str += f"@enable_trust_store{new_line}"
312
314
  method = http.urlwrap.method if http.urlwrap.method else "GET"
313
315
  output_str += f'{method} "{http.urlwrap.url}"'
314
316
  if certificate := http.certificate:
@@ -322,6 +324,8 @@ class HttpFileFormatter(RequestBase):
322
324
  output_str += f"{new_line}p12(file={apply_quote_or_unquote(certificate.p12_file)}, password={apply_quote_or_unquote(certificate.password)})"
323
325
  else:
324
326
  output_str += f"{new_line}p12(file={apply_quote_or_unquote(certificate.p12_file)})"
327
+ if trust := getattr(http, "trust", None):
328
+ output_str += f"{new_line}trust({apply_quote_or_unquote(trust.root)})"
325
329
  if auth_wrap := http.authwrap:
326
330
  if basic_auth := auth_wrap.basic_auth:
327
331
  output_str += f'{new_line}basicauth("{basic_auth.username}", "{basic_auth.password}")'
@@ -491,7 +495,7 @@ class HttpFileFormatter(RequestBase):
491
495
 
492
496
  def run(self):
493
497
  formatted = self.format(self.model, property_util=self.property_util)
494
- if self.args.stdout:
498
+ if self.args.stdout or self.args.content is not None:
495
499
  print(formatted)
496
500
  else:
497
501
  with open(self.args.file, "w") as f:
@@ -534,6 +538,13 @@ class RequestCompiler(RequestBase):
534
538
  return resp
535
539
 
536
540
  def print_script_result(self, script_result: ScriptResult):
541
+ if not (
542
+ script_result.stdout
543
+ or script_result.error
544
+ or script_result.properties
545
+ or script_result.tests
546
+ ):
547
+ return
537
548
  print("\n------------")
538
549
  if script_result.stdout:
539
550
  print("\n##STDOUT:")
@@ -568,7 +579,9 @@ class RequestCompiler(RequestBase):
568
579
  else:
569
580
 
570
581
  def func(data):
571
- return output.write(data.decode())
582
+ return output.write(
583
+ data.decode(resp.encoding or "utf-8", errors="replace")
584
+ )
572
585
 
573
586
  for data in resp.iter_content(1024):
574
587
  func(data)
@@ -631,6 +644,11 @@ class RequestCompiler(RequestBase):
631
644
  request = self.get_request()
632
645
  session.cookies = request._cookies
633
646
 
647
+ if self.httpdef.enable_trust_store:
648
+ import truststore
649
+
650
+ truststore.inject_into_ssl()
651
+
634
652
  # Create retry adapter if configured (doesn't modify session)
635
653
  retry_adapter = self._create_retry_adapter()
636
654
 
@@ -642,6 +660,11 @@ class RequestCompiler(RequestBase):
642
660
  pkcs12_password=self.httpdef.p12[1],
643
661
  ),
644
662
  )
663
+ verify = (
664
+ False
665
+ if self.httpdef.allow_insecure
666
+ else self.httpdef.trust_root or True
667
+ )
645
668
  try:
646
669
  if self.httpdef.certificate:
647
670
  cert = tuple(self.httpdef.certificate)
@@ -651,7 +674,7 @@ class RequestCompiler(RequestBase):
651
674
  # Prepare kwargs for session.send
652
675
  send_kwargs = {
653
676
  'cert': cert,
654
- 'verify': not self.httpdef.allow_insecure,
677
+ 'verify': verify,
655
678
  }
656
679
 
657
680
  # Handle proxy configuration
@@ -687,7 +710,7 @@ class RequestCompiler(RequestBase):
687
710
 
688
711
  send_kwargs = {
689
712
  'cert': self.httpdef.certificate,
690
- 'verify': not self.httpdef.allow_insecure,
713
+ 'verify': verify,
691
714
  }
692
715
  if self.httpdef.timeout:
693
716
  send_kwargs['timeout'] = self.httpdef.timeout
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dothttp-req"
3
- version = "0.0.44a35"
3
+ version = "0.0.44a37"
4
4
  description = "Dothttp is Simple http client for testing and development"
5
5
  authors = ["Prasanth <kesavarapu.siva@gmail.com>"]
6
6
  license = "MIT"
@@ -21,7 +21,7 @@ dothttp = 'dothttp.__main__:main'
21
21
 
22
22
 
23
23
  [tool.poetry.dependencies]
24
- python = ">=3.10,<3.15"
24
+ python = ">=3.12,<3.15"
25
25
  jsonschema = "4.26.0"
26
26
  jstyleson = "0.0.2"
27
27
  textx = "4.2.3"
@@ -29,14 +29,15 @@ requests-pkcs12 = "1.27"
29
29
  parsys-requests-unixsocket = "0.3.2"
30
30
  requests-aws4auth = "1.3.2"
31
31
  requests-ntlm = "1.3.0"
32
- restrictedpython = "8.2"
32
+ restrictedpython = "8.5"
33
33
  faker = "40.21.0"
34
34
  requests-hawk = "1.2.1"
35
- msal = "1.37.0"
35
+ msal = "1.38.0"
36
36
  pyyaml = "6.0.3"
37
37
  toml = "0.10.2"
38
38
  requests = "2.34.2"
39
- cryptography = "50.0.0"
39
+ cryptography = "50.0.1"
40
+ truststore = "0.10.4"
40
41
  urllib3 = "2.7.0"
41
42
  idna = "3.18"
42
43
  xmltodict = "^1.0.2"
@@ -45,12 +46,12 @@ xmltodict = "^1.0.2"
45
46
  waitress = "3.0.2"
46
47
  flask = "3.1.3"
47
48
  python-magic = "^0.4.27"
48
- flask-cors = "^6.0.1"
49
- pytest = "9.0.3"
49
+ flask-cors = "^6.0.5"
50
+ pytest = "9.1.1"
50
51
  pytest-html = "^4.2.0"
51
52
  pytest-xdist = "^3.6.1"
52
- gunicorn = "^23.0.0"
53
- httpbin = "^0.10.2"
53
+ gunicorn = "^26.2.0"
54
+ httpbin = "^0.10.4"
54
55
 
55
56
  [build-system]
56
57
  requires = ["poetry-core"]