Skip to content

Add appendToUserAgent() method to Client class#53

Merged
jeffreyparker merged 1 commit into
masterfrom
jeffrpar/append-to-user-agent/append-to-user-agent
Jul 20, 2026
Merged

Add appendToUserAgent() method to Client class#53
jeffreyparker merged 1 commit into
masterfrom
jeffrpar/append-to-user-agent/append-to-user-agent

Conversation

@jeffreyparker

Copy link
Copy Markdown
Contributor

Summary

  • Adds appendToUserAgent(string $extension) to Client, allowing callers to append custom identifiers to the User-Agent header sent with API requests
  • Matches the pattern established in duo_universal_php for consistency across Duo PHP SDKs
  • Uses a fluent interface (return $this) consistent with setRequesterOption() and disableCaPinning()

Design notes

  • Last-call-wins semantics: Subsequent calls to appendToUserAgent() overwrite the previous value rather than concatenating. This keeps the UA string predictable and matches the duo_universal_php behavior.
  • Trimming: The extension is trimmed before storage. If the result is empty/whitespace-only, nothing is appended (no trailing space in the header).
  • Private property: $user_agent_extension is private rather than public to encourage use of the setter method.

Test plan

  • Normal extension is appended after the base UA string
  • Whitespace-only input results in no extension appended
  • Leading/trailing whitespace is trimmed
  • Multiple calls overwrite (last value wins)
  • All 34 existing tests continue to pass

Allow callers to append custom identifiers to the User-Agent header,
matching the pattern established in duo_universal_php. The extension is
trimmed before storage and appended space-separated after the existing
UA string. Subsequent calls overwrite (last value wins). No-op when the
extension is empty or whitespace-only.
@jeffreyparker
jeffreyparker marked this pull request as ready for review July 15, 2026 19:17
@jeffreyparker
jeffreyparker merged commit 3ae1dad into master Jul 20, 2026
5 checks passed
@jeffreyparker
jeffreyparker deleted the jeffrpar/append-to-user-agent/append-to-user-agent branch July 20, 2026 18: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