Blasthttp mock migration#3081
Merged
liquidsec merged 4 commits intoblasthttp-integration-cleanfrom May 7, 2026
Merged
Conversation
…http.mock
Rides on blasthttp 0.5.0's new httpx-style Response API
(status_code, text, content, headers as case-insensitive Headers,
cookies, raw_headers, hash, peer_ip, request, json(),
raise_for_status() raising HTTPStatusError) and the new
blasthttp.mock submodule.
Wrapper removal
---------------
Delete bbot/core/helpers/web/blast_response.py — its job (presenting
blasthttp's PyO3 Response with an httpx-shaped surface) is now done
natively by blasthttp.Response.
- WebHelper.request: returns the native blasthttp.Response instead
of wrapping. Same downstream surface.
- WebHelper.request_batch_stream: same — yields the native
blasthttp.Response.
- download() / raise_for_status: BlasthttpHTTPError → blasthttp.HTTPStatusError.
Mock migration
--------------
bbot/test/mock_blasthttp.py is now a thin wrapper over
blasthttp.mock.BlasthttpMock. The generic mock infrastructure
(handler queue with FIFO + recycle, URL/method/header/json
predicates, sync + async callbacks, batch streaming) lives upstream.
This module keeps the bbot-specific surface:
- handle_engine_request: WebHelper kwarg translation (auth tuple
→ Authorization header, cookies dict → Cookie header,
json/data body assembly, raise_error → engine-style error dict,
allow_redirects → follow_redirects).
- handle_batch_stream(real_client, ...): per-call real_client
splitting, since the WebHelper's blasthttp client isn't available
at fixture construction time.
`MockRequest`, `MockResponse`, `TimeoutException`, and the
`add_response` / `add_callback` / `should_intercept` API are all
re-exported / forwarded so the 68 module tests using them keep
working unchanged.
Module-level fixes for the new Headers API
------------------------------------------
The blasthttp.Headers class iterates as Python-dict-style keys
(httpx convention), not list-of-tuples. Three places in bbot
were unpacking headers as tuples:
- http.py: replaced manual raw_header build with
response.raw_headers (also lazy on the blasthttp side).
header_dict loop now uses .items().
- web_brute.py: location lookup uses .items().
- url_manipulation.py: subject_content now uses raw_headers
instead of stringifying the list of tuples.
diff.py compare_headers needed no special handling — blasthttp
0.5.0 registers Headers with collections.abc.MutableMapping so
DeepDiff recognizes it natively.
Pin
---
pyproject.toml: blasthttp dep bumped >=0.3.2 → >=0.5.0.
Contributor
📊 Performance Benchmark Report
📈 Detailed Results (All Benchmarks)
🎯 Performance Summary! 1 regression ⚠️
23 unchanged ✅🔍 Significant Changes (>10%)
🐍 Python Version 3.11.15 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## blasthttp-integration-clean #3081 +/- ##
============================================================
+ Coverage 91% 91% +1%
============================================================
Files 440 439 -1
Lines 38111 37860 -251
============================================================
- Hits 34374 34159 -215
+ Misses 3737 3701 -36 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
No description provided.