Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add User-Agent header to outgoing HTTP requests #19

Merged
merged 1 commit into from
Aug 27, 2024
Merged

Conversation

jake-low
Copy link
Contributor

@jake-low jake-low commented Aug 22, 2024

Excludes requests made by the AWS SDK to read/write data in S3, but includes all other HTTP requests made during operation, e.g. when getting changeset metadata from the OSM API, or when querying the Overpass server.

The header is formatted as User-Agent: OSMCha osm-adiff-service 1.0.0

This PR also replaces the Node http module for the 3rd-party node-fetch which implements the WhatWG Fetch API. Using Fetch simplifies the HTTP request code somewhat since it supports promises and URL parsing, which http does not. Node 21 includes native support for fetch so at some point if we update Node we can drop the third-party node-fetch dependency.

I've tested this change locally by running yarn process <replication-id>. However to do so I had to modify index.js significantly, removing the S3 API calls and using plain HTTP to read data from S3 (and skip writing data entirely). I'm reasonably sure that I still hit all of the important code paths, but let me know if there's a better way to test this code.

Excludes requests made by the AWS SDK to read/write data in S3, but
includes all other HTTP requests made during operation, e.g. when
getting changeset metadata from the OSM API, or when querying the
Overpass server.
@jake-low jake-low requested a review from willemarcel August 22, 2024 23:53
Copy link
Contributor

@willemarcel willemarcel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's working great. Thanks, @jake-low!

@willemarcel willemarcel merged commit af3e39e into main Aug 27, 2024
2 checks passed
@willemarcel willemarcel deleted the jlow/user-agent branch August 27, 2024 17:47
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.

2 participants