Conversation
The rule for collecting headers one at a time — combine a repeated name the way a receiver combines field lines, compare names case-insensitively, keep the spelling first seen — was private to the curl parser, and the HAR importer will need exactly the same behaviour. Move it to header_tools/header_merge, where generic header logic already lives, and drop the content-type constant the curl parser no longer used.
Each target template was one function that emitted its import line, its call and its trailing print together, so a caller writing several requests into one script could not reuse any of it. Split out the call block, the pytest function (with an optional name for when several tests share a file) and the APITestka action as data, then build the single-request templates from those pieces. The generated text is unchanged.
Copying one request as cURL covers one call; a browser can save the whole session as HAR. The new tool reads that export, lists each recorded call with its method, path, status and media type, and hides page assets (stylesheets, images, fonts) behind a filter so what is left is the API traffic worth testing. Selected calls are generated into one script for the same targets the cURL importer offers: a pytest file with one test per call, an APITestka action list replaying the flow in capture order, a requests walkthrough, an APITestka script, or LoadDensity runs. Repeated endpoints get numbered test names so no test silently replaces another, and the load-test target emits one run per call because the shared task template holds a single URL per HTTP method. Recorded headers, cookies, query parameters and bodies (raw, URL-encoded and multipart) map onto the existing CurlRequest, so every generator and tool already accepts them. HTTP/2 pseudo-headers are dropped, and a Cookie header duplicating the recorded cookie list is removed so nothing is sent twice. A single selected request generates exactly what the cURL importer would.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 129 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
The response analyzer kept its own copy of the token pattern so it could spot a JWT inside a larger text. That scan belongs with the decoder, and the header analyzer needs it too. Expose find_tokens there, returning the distinct tokens in the order they appear, and have the response analyzer use it.
Three findings still had to be copied between tools by hand. Each now opens where it belongs, pre-filled: - the cURL importer opens its parsed headers in the header analyzer - the header analyzer opens a bearer token found in any header in the JWT decoder, decoded - the response inspector opens a JSON body in the JSON format tool, already pretty-printed Each button stays disabled until the analysis actually has something to hand over, so it never opens an empty tab. The JSON format tool gained the initial_json argument the hand-off needs, matching how the decoder, status reference, URL builder and header analyzer are pre-filled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What changed
Copying one request as cURL covers one call; a browser can save the whole session as HAR. This adds a tool that reads that export and generates a test suite from it, reusing everything the cURL importer already has.
HAR Import (new tool)
Open a
.harfile and every recorded call is listed with its method, path, status and media type. Page furniture — stylesheets, images, fonts — is filtered out by default, so what remains is the API traffic worth testing. Select the calls you want, or take everything listed, and generate one script for the whole set using the same targets as the cURL importer:requestswalkthrough, an APITestka Python script, or LoadDensity runsRecorded headers, cookies, query parameters and bodies (raw, URL-encoded and multipart, including file uploads) map onto the existing
CurlRequest, so every generator and tool already accepts them. HAR is JSON, so this needs nothing beyond the standard library, and nothing is ever replayed for you.Details worth calling out
tasks.items(), which is keyed by HTTP method — merging several captured calls into onetasksdict would keep only the lastGET. Each call therefore gets its ownstart_testrun, with a comment saying why.test_get_api_items_2).Cookieheader; the structured list wins and the duplicate header is dropped. HTTP/2 pseudo-headers (:method,:authority) are dropped too, since passing them on produces code that fails.Supporting refactors (separate commits)
header_tools/header_merge, where both importers use it.Verification
ruff check .— cleanpytest test/test_utils— 824 passed (65 new, including a hypothesis property thatparse_haron an arbitrary JSON document either returns entries or raisesHarParseException, never a bareKeyError/TypeErrorfrom a mistyped HAR field)test_language_parity.py— English/Chinese keys and placeholders in parity