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

[BUG] SDK fails to make proper requests when provided with non-ascii chars #31

Open
mdb-intive opened this issue Dec 8, 2023 · 0 comments

Comments

@mdb-intive
Copy link

The implementation to make requests in the SDK assumes an ascii encoding (meaning each character in the JSON string will map to 1 byte) but this is not always true.

Example request that fails when using the SDK but works using any other HTTP client (axios, curl, LR API docs, etc.):

POST https://api.loginradius.com/identity/v2/manage/account

{
  "FirstName": "José",
  "Email": [
    {
      "Type": "Primary",
      "Value": "[email protected]"
    }
  ],
  "Password": "fake-password"
}

The problem is that the "Content-Length" header is set using the length of the string and not the length of the byte array. For example, the word "José" has a length of 4 characters but it has a length of 5 bytes when turned into a byte array (buffer). That means that the SDK is incapable of sending that perfectly valid request to the LR API.

The change needed is rather simple (one line change) and I can create a PR if needed.

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

No branches or pull requests

1 participant