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

getUserAgent() doesn't properly get the header because of conversion. #35

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

ruiwashere
Copy link
Contributor

Hi guys!👋

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe below

Description

request()->getUserAgent() doesn't return the user agent because it can't find the proper header name of it.

The code flow is the following:

getUserAgent()
→ Headers::get('HTTP_USER_AGENT')
→ self::all()
→ findHeaders()
→ transforms 'HTTP_USER_AGENT' to 'User-Agent'
→ lookup fails because of the wrong key.

Fixing it

Inside Requests.php -> Request Class -> getUserAgent() Method;
We can simply "return Headers::get('USER-AGENT');" instead of "Headers::get('HTTP_USER_AGENT');.

Does this PR introduce a breaking change?

  • Yes
  • No

Related Issue

Copy link
Member

@mychidarko mychidarko left a comment

Choose a reason for hiding this comment

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

Thanks for catching this

@mychidarko mychidarko merged commit 476a4ae into leafsphp:v3.x Jan 29, 2025
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