pass user agent and allow response.status 2xx#199
Open
PatrickSteil wants to merge 1 commit into
Open
Conversation
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.
Fix GTFS URL download failures
Some GTFS URLs that work fine in a browser would fail silently when downloaded by node-gtfs. Two bugs in
downloadGtfsFileswere responsible:1. Missing
User-AgentheaderNode's
fetchsends noUser-Agentby default. Many transit agency servers (especially government ones) block or reject requests without one, while browsers succeed because they always identify themselves. A defaultUser-Agent: node-gtfsheader is now sent, with any user-supplied headers still taking precedence.2.
status !== 200check was too strictReplaced with
!response.ok, which correctly accepts any2xxresponse. Some servers return206 Partial Contentor other valid success codes for file downloads, which the old check would incorrectly treat as errors.Also added explicit
redirect: 'follow'for clarity.Changes
src/lib/import-gtfs.ts