Net-Base Magazine

24.10.2026

System.Net.HttpClient: Resumable Downloads — Range Requests, ETag Validation and Clean Partial-File Strategy

When downloads are interrupted, resuming is tempting — and risky. How to combine Range requests, If-Range/ETag and a robust .part strategy without introducing silent file corruption.

24.10.2026

From magazine topic to project implementation

Relevant service and technical pages for this post

The scene is unpleasant but typical: a nightly job downloads a large archive, the progress bar is at 93 %. Then a short VPN glitch, timeout, abort. In the morning there is a file in the target directory, size “looks right”, but when unpacking it only reports “unexpected end of file”. Anyone who reflexively adds “resume” quickly encounters the next edge case: the download completes, but is assembled from two versions.

That is exactly what an HttpClient download with resume is for—but only if you treat it like a small data pipeline: with clear rules about when you may append, how you verify version fidelity (ETag/If-Range) and how you manage local intermediate states (partial files) so that operations and debugging do not become a guessing game.

The conflict of goals is clearly identifiable: saving bandwidth and time (resume instead of restart) versus integrity and maintainability (no silent version mix, traceable decisions, reproducible failure modes). This article is structured as a decision map: benefits, effort, risks, limits — and a pragmatic line on when you should actually implement resume and when a good retry is the better choice.

Decision map: two goals, a hard trade-off

Resume is not worthwhile because it is “modern”, but because your environment forces it: large files, unstable links, batch time windows, users who abort downloads, or services that should continue after a restart where they left off. At the same time, resume is the point at which unnoticed data corruption can be introduced—and that often only becomes visible much later (import fails, signature invalid, setup won’t run).

Situation Resume benefit Typical risk Plausible decision
Large files over WAN/VPN or mobile networks high (time, bandwidth) “200 instead of 206” is blindly appended Use resume, but defensively (status/Content-Range/validator)
“latest” URLs / artifacts without version binding medium version mix after an intermediate update Resume only with a strong validator; otherwise restart
Internal storage with stable ETags high low, if headers are consistent Resume very well suited; persist metadata
Small files (a few dozen MB) low complexity outweighs benefit Full download + retry/backoff is usually better
Changing proxies/CDNs, unclear header situation unclear inconsistent validators, difficult debugging Only with good logging; otherwise deliberately conservative

Why Resume is more than just “setting Range”

HTTP supports byte-range requests via the Range header. The important, often overlooked sentence: Range support is optional. A server may ignore Range and respond as if it were a normal GET — i.e., with 200 OK and a full body. For clients this means: the truth is in the response, not in your request intent.[Quelle]

A Resume client that confuses “Range sent” with “partial content is coming” makes exactly the mistake you saw at the start of the scenario: a full download is appended to an already partially downloaded file. Result: the file appears large enough, but is logically corrupted.

Success signal: 206 plus a plausible Content-Range

When Resume actually works, you typically see:

  • Status 206 Partial Content instead of 200 OK
  • Content-Range with range unit bytes and the expected start offset
  • consistent validators (e.g., ETag), if you use them for version fidelity

These checks are not “nice to have”. RFC 9110 explicitly states that recipients must not compose a 206 response with an unknown range unit together with a stored representation. Practical consequence: without a correctly understood Content-Range, no append.[Quelle]

If-Range and ETag: the clean way to avoid version mixing

The core problem when resuming is not the technique of appending, but the question: are you still downloading the same resource? HTTP provides validators for that. ETag (Entity Tag) is the most precise lever: a server-side identifier for a concrete representation. Last-Modified is a timestamp, often useful, but less precise (time resolution, repackaging, different intermediates across CDNs).

The mechanism for “Range only if it really is the same version” is If-Range: you send Range plus a condition. If the validator matches, the range is returned; if it does not match, the server should send the complete resource. For ETags: the condition is only satisfied on a strong ETag match (strong comparison). This is not a matter of interpretation, but specified in the standard.[Quelle]

Operational reality remains: if the server does not support Range, it must ignore If-Range. This sounds academic, but it is a direct requirement for your client: you must also expect 200 OK and derive a hard decision from it (restart, do not append).[Quelle]

Partial-file strategy: the local counterpart to HTTP semantics

Resume means: you manage local state. And that state must remain stable after a crash, restart, concurrent starts, or user actions („click again“). A clean partial-file strategy consists of three artifacts:

  • Partial file as the single write target during the download (e.g., foo.zip.part)
  • Metadata stored separately (e.g. foo.zip.part.meta.json): URL, timestamp, ETag, Last-Modified, expected length (if known), optionally Content-Type, and the local length at the last clean flush
  • Atomic completion: only after full download and a plausibility check is it renamed/replaced to the final name

Why metadata? Because otherwise on the next start you only know the file length – but not whether it belongs to that server version. That exact information determines whether you may resume.

HttpClient download with resume: decision logic you can test

System.Net.HttpClient gives you requests, responses and streams. Robustness comes from your decision matrix. If you formulate it clearly, you can also test it thoroughly (including “server ignores Range”, “validator mismatch”, “416”).

Minimal process in 6 steps

  1. Determine local state: Does .part exist? Read length as offset. Load metadata.
  2. Decide resume capability: Only attempt resume if offset > 0 and at least one usable validator is present in the metadata (prefer ETag).
  3. Build request: Set Range from the offset. Also set If-Range (ETag, otherwise Last-Modified).
  4. Classify response:
    • 206: parse Content-Range, check Range-Unit bytes, start offset must match exactly. Only then append.
    • 200: never append. Discard or quarantine the partial state, re-download.
    • 416 Range Not Satisfiable: offset no longer matches (locally or server-side). Reset state and restart.
    • otherwise: error path with clear diagnosis (log status code + headers).
  5. Write stream: in blocks, flush regularly, update metadata (e.g. “last flush at length X”).
  6. Completion: size/plausibility check (if possible). Then atomically rename/replace.

RangeHeaderValue: not a minor detail, but error prevention

.NET provides the typed class RangeHeaderValue for the Range header. This is not just “nicer code”: it reduces syntactic header errors and makes logs more interpretable, because you produce consistent values. Microsoft also documents the operationally relevant caveat: servers are not required to support range requests; Accept-Ranges is a hint, not a guarantee.[Source]

Constructed example: when “200 OK” breaks your resume

Typical pitfalls and how to spot them in your logs

Accept-Ranges: a useful signal, but no guarantee

Many teams use Accept-Ranges as an indicator that the server supports resume. MDN describes the header exactly that way as a support indicator (“anything except none”). That is useful for diagnosis and telemetry. Still: never decide based on it alone. A proxy, an auth gateway or a CDN can change the behavior. Your logic must therefore always rely on the status code (206 vs. 200) and on Content-Range, not on the hopeful hint in Accept-Ranges.[Source]

Weak ETags (W/…) and transformations

Weak ETags (W/"…") appear more often than one would like. For If-Range, however, a strong ETag match is decisive. In practice this means: if you only get a weak ETag, resume is less reliable. You can still use it, but you should be more conservative (e.g., restart on the smallest discrepancy) and for particularly critical files additionally rely on an out-of-band integrity check (hash from manifest/API), if available.

Unknown total length (chunked) and missing plausibility

If no Content-Length is provided (e.g. chunked transfer), you lose the simple completion check “local length == expected length.” Resume can still work, but you need robust validators and good logging. Without those supports, debugging becomes slow because you cannot even tell whether bytes are missing or there are too many.

Parallelization: only once the basics are solid

Downloading multiple ranges in parallel is possible, but it multiplies state problems: segment management, random-write, merge, error logging, retry per segment. For many process-near software solutions this is overkill. Most stable gains often come from: serial download + resume + a clear decision matrix. Parallelization is worthwhile only after you have demonstrated stable range support and concrete measurements show you are truly limited by the network or the server.

Debugging that delivers clarity in 5 minutes

Resume bugs are rarely „just a wrong if“. Most often it’s a combination of infrastructure (proxy/CDN), server configuration, timeouts and local state. That’s why structured logging per attempt pays off. Not as a text blob, but as consistent fields:

  • Request: URL (without secrets), method, Range (start/end), If-Range (ETag or date).
  • Response: status code, Accept-Ranges, ETag, Last-Modified, Content-Length, Content-Range (raw and parsed).
  • Local state: part path, part length before request, write mode (append/overwrite), length after writing.
  • Decision: „Resume accepted“, „Resume rejected (200) – RESTart“, „416 – reset“, „Validator mismatch – RESTart“.

With exactly this data you can test hypotheses: „Does the server ignore Range?“, „Does the ETag change between requests?“, „Is the offset computed incorrectly?“, „Is a second process writing?“ – without having to fire up Wireshark first.

When to deliberately not implement resume

The cleanest architectural decision is sometimes to omit resume — not out of convenience, but because in your scenario it creates more failure surface than benefit:

  • URL without version binding: If the same URL regularly serves new content, resuming without a strong validator is an integrity risk.
  • No usable validators: If neither ETag nor Last-Modified are consistent, „resuming“ is a gamble. For critical imports that’s often worse than a controlled RESTart.
  • Downloads small and frequent: Here retry strategies (timeouts, backoff, possibly mirror URL) are more maintainable and easier to explain in operation.

Pragmatic safety nets that pay off

Quarantine instead of deleting

If a resume attempt fails, don’t reflexively delete the .part. Rename it (e.g. .part.bad + timestamp). That makes server/proxy issues visible because you can later compare response headers and file state. And it prevents a rare problem from disappearing from analysis due to „cleanup“.

Locking to prevent concurrent starts

If two processes write the same .part at the same time, all HTTP validators become worthless. An exclusive lock (file lock or system-wide mutex) is therefore not a luxury but basic protection. Metadata can additionally carry an owner information (instance ID) so you can identify and clean up „orphaned“ downloads.

Quick rules you really need

  • Append only on 206 – and only with a validated Content-Range (unit bytes, start offset matches).
  • 200 means: RESTart (overwrite), never append to a partial file.
  • If-Range reduces version mixing, but does not replace the requirement to evaluate status and Content-Range.
  • 416 is a reset signal: local offset no longer matches, discard/quarantine the state.

Final point: integrity first, then optimization

An HttpClient download with resume is good when it is boring: it sets Range only when the local state is reliable, it resumes only on 206 together with a verified Content-Range, and it prevents version mixing via If-Range and validators. Everything else is a “looks fast” feature that will cost you time later, because errors are rare and then hard to reproduce.

If you want to set up a robust download pipeline (resume, logging, partial-file strategy, operational boundaries) cleanly for updaters, import paths or services, this can often be resolved in a short architecture check — including the question whether the complexity is justified in your environment. Get in touch and discuss the project with Net-Base.

Sources and further information

The technical core statements were editorially contextualized based on the following external sources.

  1. RFC 9110: HTTP Semantics (www.rfc-editor.org)
    HTTP range requests are optional; servers may ignore Range and respond as with a normal GET, so the client must evaluate status code and headers instead of blindly attempting to resume.
  2. HTTP range requests – HTTP | MDN (developer.mozilla.org)
    Accept-Ranges is a signal of range support, but clients must robustly verify the response behavior (206/Content-Range).
  3. RangeHeaderValue Class (System.Net.Http.Headers) | Microsoft Learn (learn.microsoft.com)
    .NET provides a typed representation of the Range header with RangeHeaderValue; servers are not required to support range requests.

Discuss a project or modernization initiative with Net-Base.

Next step

When the topic becomes an actual project, architecture, existing systems and operations should be considered together from the outset.

We support not only with individual issues, but also when source snippets, legacy topics, or portal ideas are to be turned into a robust enterprise project.

  • Current state, target state and technical risks are assessed jointly.
  • REST, data access, portals and rollout are not deferred to a later stage as secondary consequences.
  • You can see early on which path is economically and operationally viable.

Share post

Share this post directly

LinkedIn, X, Facebook, WhatsApp und E-Mail sind sofort verfügbar. für Instagram bereiten wir Link und Kurztext direkt vor.

Email

Instagram opens in a new tab. The link and short text are copied to the clipboard beforehand.

Write comment

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert