Skip to content

Say which extra headers the copy will not send - #258

Merged
xroche merged 3 commits into
masterfrom
warn-dropped-headers
Oct 25, 2026
Merged

xroche merged 3 commits into
masterfrom
warn-dropped-headers

Conversation

@xroche

@xroche xroche commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

The engine explains each refused header on stderr, which this app discards, so the header goes missing and nothing says why.

Leaving the Browser ID page now names every line the crawl will not send as typed. The reason comes from hts_custom_header_verdict, which httrack #2006 exports, so nothing here knows what the engine refuses.

The engine keeps the LAST line of a repeated Host, Cookie or Authorization, so the line the user loses is an earlier one. Asking about one earlier line alone is how the engine says which.

The pin bump makes the symbol reachable. It also carries engine #2004, which names the cookie size caps, so three cookie tests read macros now.

A profile loaded from winprofile.ini never passes through this page, so its headers go unchecked.

The engine refuses a framing header on -%X, refuses a line that names no
header, and keeps only the last of Host, Cookie and Authorization. It
says why with fprintf on stderr, which this app discards, so a header
the user typed was silently never sent and nothing explained it. Leaving
the Browser ID page now names each dropped line.

The engine's two lists are copied here, which is the part that could rot,
so the test reads them back out of the pinned engine source and compares.
Changing the engine's own array turns it red, so a pin bump cannot move
the list quietly.

Asking the engine instead would have been better and is not available.
http_custom_header_warning returns exactly this verdict, but it is
declared inside #ifdef HTS_INTERNAL_BYTECODE and carries no HTSEXT_API,
so it is neither visible to our translation unit nor exported from
libhttrack for libhtslibjni to call. A JNI wrapper fails to compile. If
the engine ever promotes it, this class should call it and drop the copy.

A profile loaded from winprofile.ini never passes through this page, so
its headers go unchecked.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <xroche@gmail.com>
xroche added a commit to xroche/httrack that referenced this pull request Oct 25, 2026
This exports `hts_custom_header_verdict()`, so a front end can ask the
engine which `-%X` lines it will drop, rather than copying the rules.
httrack-android needs it for xroche/httrack-android#258, whose Java copy
got two rules wrong.

A new verdict, `HTS_HEADER_SENT_UNLESS_ENGINE_OVERRIDES`, covers `Range`
and the four `If-*` conditionals. The engine writes those itself on an
update or a resume, and then drops the user's line. The `-%X` warnings
and the settings-bundle refusals do not change. The soname does not
move, because the change only adds a symbol.

---------

Signed-off-by: Xavier Roche <roche@httrack.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
xroche and others added 2 commits October 25, 2026 13:28
The first cut of this copied the engine's two header-name lists and its
three refusal rules into Java. Two of the rules came out wrong: it named
the surviving line of a repeated Host as the dropped one, and it called a
blank before the colon malformed where the engine strips it and sends the
header.

httrack #2006 exports the verdict, so all of that goes. HeaderWarnings now
asks hts_custom_header_verdict per line and maps the answer to a reason,
and the pin bump to e5401d49 is what makes the symbol reachable.

Two findings from the same review are fixed here too. "Line N" counts the
lines the user can see rather than the ones the engine gets, and the
tablet-mode Back path warns on the way out instead of never.

The bump also carries engine #2004, which gives the cookie size caps
names, so three cookie tests read those macros instead of literals.

A hand-run ndk-build writes into app/src/main, which the Gradle build
never does, so .gitignore now covers those two directories.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
The mutation matrix left three mutants alive, so three cases are new:
a dropped line is still handed to the engine as an earlier line, a
conditional line is reported inside a longer box as well as alone, and a
repeat with an unrelated line between the two now fails the test whose
name claims it.

The test-input glob missed winprofile-keys.tsv and html/guide.html, which
two existing source-text tests read, so those guards could still go
UP-TO-DATE on a pin bump.

The tablet-Back decision moves into warnsBeforeLeaving, where a plain
test reaches it. A grep guard over the callback would not hold the
invariant.

Also drops a stale comment the first commit left stranded above the
fault-latch allowlist, which still said three entries.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche enabled auto-merge (squash) October 25, 2026 12:42
@xroche
xroche merged commit 4e8325c into master Oct 25, 2026
7 checks passed
@xroche
xroche deleted the warn-dropped-headers branch October 25, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant