Skip to content

Fix swapped X-Afterpay-SDK request header name and value - #303

Open
Avicennasis wants to merge 1 commit into
afterpay:masterfrom
TypoScan3000:docs/fix-typos
Open

Avicennasis wants to merge 1 commit into
afterpay:masterfrom
TypoScan3000:docs/fix-typos

Conversation

@Avicennasis

Copy link
Copy Markdown

Summary of Changes

  • ApiV3.configure() (afterpay/src/main/kotlin/com/afterpay/android/internal/ApiV3.kt) and AfterpayCashAppApi.configure() (afterpay/src/main/kotlin/com/afterpay/android/cashapp/AfterpayCashAppApi.kt) call connection.setRequestProperty("${BuildConfig.AfterpayLibraryVersion}-android", "X-Afterpay-SDK"). setRequestProperty takes (key, value), so every V3 and Cash App Pay request sends a header named after the SDK version (<version>-android: X-Afterpay-SDK) instead of X-Afterpay-SDK: <version>-android.
  • Swapped the two arguments in both files. The iOS SDK already sends X-Afterpay-SDK with the SDK version as the value (Sources/Afterpay/ApiV3.swift).

Items of Note

This is a small behaviour change, not a comment fix: requests will now carry a real X-Afterpay-SDK header and stop sending the version-named one. No test was added. The existing AfterpayCashAppApiTest stubs setRequestProperty(any(), any()). I'm happy to add an assertion on the header if you'd like one.

The change is limited to the two setRequestProperty lines.

HttpsURLConnection.setRequestProperty takes (key, value), but ApiV3 and
AfterpayCashAppApi passed the SDK version string as the header name and
"X-Afterpay-SDK" as its value. Swap the arguments so requests carry
X-Afterpay-SDK: <version>-android, matching the iOS SDK.

Signed-off-by: Léon Avic Simmons <Avicennasis@gmail.com>

This branch has not been deployed

No deployments
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