Skip to content

Check HTTP status and Content-Length before parsing - #24

Merged
saulpw merged 1 commit into
masterfrom
http-status-check
Feb 19, 2026
Merged

Check HTTP status and Content-Length before parsing#24
saulpw merged 1 commit into
masterfrom
http-status-check

Conversation

@saulpw

@saulpw saulpw commented Feb 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Validate HEAD response status is 2xx before trying to parse zip structure
  • Check for Content-Length header presence, instead of crashing with KeyError
  • Uses the existing error() function for clean error messages

Inspired by error cases reported in saulpw/visidata#2655 by @midichef.

Test plan

  • Verify normal .zip URLs still work
  • Verify a 404 URL gives cannot open URL: HTTP status 404 instead of a KeyError traceback
  • Verify a URL with no Content-Length gives a clear error

🤖 Generated with Claude Code

Validate the HEAD response status (must be 2xx) and the presence of
Content-Length header, raising clear errors instead of cryptic KeyError
or struct unpacking failures.

Co-Authored-By: midichef <midichef@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
saulpw added a commit to saulpw/visidata that referenced this pull request Feb 15, 2026
Vendor updated unzip_http.py with HTTP status and Content-Length
validation (saulpw/unzip-http#24). Catch errors from infolist() in
iterload() so users see clean failure messages instead of tracebacks.

Co-Authored-By: midichef <midichef@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
saulpw added a commit to saulpw/visidata that referenced this pull request Feb 19, 2026
Vendor updated unzip_http.py with HTTP status and Content-Length
validation (saulpw/unzip-http#24). Catch errors from infolist() in
iterload() so users see clean failure messages instead of tracebacks.

Co-Authored-By: midichef <midichef@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@saulpw
saulpw merged commit 7006dc0 into master Feb 19, 2026
1 of 3 checks passed
@saulpw
saulpw deleted the http-status-check branch February 20, 2026 18:51
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