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

Set default user agent in proxy client #1843

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

welteki
Copy link
Member

@welteki welteki commented Aug 6, 2024

Description

Set a default user agent for the http proxy client, openfaas-ce-gateway/<version> if the proxied request does not have the User-Agent header.

Motivation and Context

  • I have raised an issue to propose this change (required)
  • My issue has received approval from the maintainers or lead with the design/approved label

The gateway used to inject the default golang user agent, Go-http-client/1.1, into requests. This change ensures the default user agent is set correctly.

How Has This Been Tested?

Verified the gateway user agent header is injected if a request does not contain a user agent header.

curl -i "http://127.0.0.1:8001/function/env" -H "User-Agent:"

TTP/1.1 200 OK
Content-Length: 994
Content-Type: text/plain; charset=utf-8
Date: Tue, 06 Aug 2024 13:56:26 GMT
X-Call-Id: 38929e79-5e13-4369-a9d1-93a71101a058
X-Duration-Seconds: 0.000604
X-Served-By: openfaas-community/
X-Start-Time: 1722952586671966988

...
Http_User_Agent=openfaas-ce-gateway/dev
...

Verified the user agent from the original request is forwarded.

curl -i "http://127.0.0.1:8001/function/env"      
HTTP/1.1 200 OK
Content-Length: 982
Content-Type: text/plain; charset=utf-8
Date: Tue, 06 Aug 2024 13:55:37 GMT
X-Call-Id: 5719114d-1032-41ae-87ac-813eefcc4019
X-Duration-Seconds: 0.000715
X-Served-By: openfaas-community/
X-Start-Time: 1722952537702282995

...
Http_User_Agent=curl/7.81.0
...

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Signed-off-by: Han Verstraete (OpenFaaS Ltd) <[email protected]>
@alexellis alexellis merged commit 4e80b96 into openfaas:master Aug 7, 2024
1 check passed
@welteki welteki deleted the user-agent branch August 8, 2024 16:13
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