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 Request Headers (User-Agent, Referer, Origin) to Prevent 403 Errors on Some Web Servers #165

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ferrenza
Copy link

@ferrenza ferrenza commented Mar 3, 2025

I know that a similar PR was submitted before (#163) and was closed, but can this be reconsidered?

Some web servers enforce strict header policies to protect their content. In our case, using the default Apache HttpClient headers resulted in errors, as evidenced by the following log entry:

xxx.xxx.xx.xx - - [04/Mar/2025:03:40:44 +0700] "GET /source.mp3 HTTP/1.1" 403 3444 "-" "Apache-HttpClient/4.5.14 (Java/17.0.14)"

This indicates that the default headers are insufficient, leading to HTTP 403 errors when accessing audio content.

Changes:

  • Update the getConnectRequest() method to include custom HTTP headers:
    • User-Agent: Mimics a modern browser (Chrome/Edge) to prevent server-side rejections.
    • Referer: Set to the full target URL.
    • Origin: Constructed using the URI’s scheme, host, and port (if applicable) to accurately represent the request source.

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