[refactor] add Progressive HEAD simulation & Stream utility functions#19
Merged
[refactor] add Progressive HEAD simulation & Stream utility functions#19
Conversation
Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for simulating HEAD requests in HTTPClient
feat: HTTPClient.head() with progressive HEAD simulation fallback
Mar 7, 2026
…t Staged 16 & other latest Upstream packages/actions [optimize] simplify Copilot codes
TechQuery
requested changes
Mar 8, 2026
…nto defaultWare Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
TechQuery
requested changes
Mar 8, 2026
…bytes before cancel Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
TechQuery
requested changes
Mar 8, 2026
…uest for HEAD; head() uses this.request() Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
[optimize] simplify Copilot codes
TechQuery
requested changes
Mar 8, 2026
…ytes/readBytes tests to utility.spec.ts Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
TechQuery
requested changes
Mar 22, 2026
Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com> Agent-Logs-Url: https://github.com/EasyWebApp/KoAJAX/sessions/4ae98639-f3ac-4b8f-958d-53c3880dbd8b
[optimize] upgrade to JSDOM 29 & other latest Upstream packages [optimize] move Stream Utility tests to independent file [fix] some Copilot bugs
TechQuery
approved these changes
Mar 24, 2026
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.
HTTPClient.head()previously threw when a server didn't supportHEAD. This adds a three-tier fallback chain to simulate HEAD using minimal bandwidth.Fallback chain
All three tiers use
fetch()directly and are encapsulated entirely insiderequestHead(), which is called from within the exportedrequest()function:fetch()— standardfetch()HEAD request; return on successGETwithRange: bytes=0-4099(magic number size per file-type); returns headers (includingContent-Range) and the first 4100 bytes as anArrayBufferfetch()— reads exactly the first 4100 bytes from the response body using an async generator (for await...of+ slice at limit +Array.fromAsync()) then cancels the stream; bytes returned inbodyChanges
source/HTTPRequest.ts—requestHead(req)encapsulates the full three-tier chain; all tiers usefetch()directly (nobaseRequestparameter); exportsFILE_TYPE_MAGIC_NUMBER_SIZE = 4100constant andHeadResponseinterface ({ headers, body?: ArrayBuffer }); the exportedrequest()function wrapsrawRequest(XHR/fetch) and for HEAD requests delegates torequestHead(), returning a syntheticResponse{status:204}; non-HEAD requests pass through torawRequestunchangedsource/utility.ts— exportstakeBytes(stream, limit)async generator acceptingReadableStream<Uint8Array>directly; reads chunks viafor await...of,yields each (slicing the final chunk to honour the limit exactly), andbreaks oncelimitbytes have been produced; theas unknowncast is internal so callers need no type assertions; exportsreadBytes(stream, limit)that collects the result viaArray.fromAsync()into anArrayBuffer; used byrequestHead()for tier 3source/HTTPClient.ts—head()is a plainthis.request()wrapper going through the normal middleware chain; HEAD simulation is transparent at therequest()layer;defaultWareis a simple throw for status > 299 with no HEAD special casetest/XMLHttpRequest.ts— simplified mock: dead HEAD→405 special case removed (XHR is no longer called for HEAD)test/Request-Client.spec.ts— four tests covering all three fallback tiers and therequest()wrapper; Range GET mock includesContent-Rangeresponse header;requestHead()calls omitmethod; expected synthetic status is204test/utility.spec.ts— four tests fortakeBytesandreadBytesusingnew Blob([...]).stream()for stream creation (no manualmakeStreamhelper); tests verify exact byte-count behaviour and unlimited collection; noas/unknown/anycasts at call sitespackage.json— parcel updated to^2.16.4to fix a pre-existing Node.js v24 worker thread crash in the build stepHuman changes
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.