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

fix HTTP error 403: forbidden #270

Merged
merged 1 commit into from
Jan 30, 2024
Merged

Conversation

doneachh
Copy link
Collaborator

Closes # (if applicable).

Changes proposed in this Pull Request

deleted storage options to fix HTTP 403 forbidden error

Checklist

  • I tested my contribution locally and it seems to work fine.
  • Code and workflow changes are sufficiently documented.
  • Newly introduced dependencies are added to envs/environment.yaml and envs/environment.docs.yaml.
  • Changes in configuration options are added in all of config.default.yaml, config.tutorial.yaml, and test/config.test1.yaml.
  • Changes in configuration options are also documented in doc/configtables/*.csv and line references are adjusted in doc/configuration.rst and doc/tutorial.rst.
  • A note for the release notes doc/release_notes.rst is amended in the format of previous release notes, including reference to the requested PR.

@doneachh doneachh linked an issue Jan 30, 2024 that may be closed by this pull request
2 tasks
@doneachh doneachh requested a review from energyLS January 30, 2024 10:30
@@ -20,8 +20,7 @@ def download_ports():
The following csv file was downloaded from the webpage https://msi.nga.mil/Publications/WPI as a csv file that is updated monthly as mentioned on the webpage. The dataset contains 3711 ports.
"""
fn = "https://msi.nga.mil/api/publications/download?type=view&key=16920959/SFH00000/UpdatedPub150.csv"
storage_options = {"User-Agent": "Mozilla/5.0"}
wpi_csv = pd.read_csv(fn, index_col=0, storage_options=storage_options)
wpi_csv = pd.read_csv(fn, index_col=0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you explain why storage_options is deleted and what the purpose was?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@energyLS When downloading csv files with pd.read_csv, the storage_options are transferred as header in the request. They are there to make the request look more "credible", in this case to indicate that the request is being sent from a Mozilla Firefox browser. For some reason, however, this is exactly what triggers this HTTP error 403. As soon as we do not send this header, we get the data packet returned. :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, great catch. Merging!

@energyLS energyLS merged commit 7dd966f into main Jan 30, 2024
5 checks passed
@doneachh doneachh self-assigned this Feb 1, 2024
@davide-f davide-f deleted the 269-http-error-in-rule-prepare_ports branch March 15, 2024 14:10
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.

HTTP error in rule prepare_ports
2 participants