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

Replace FormUrlEncodedContent with StringContent #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bojidar-danchev
Copy link

I have found a bug in the Kutt API which results in 'false' or 'False' to be considered a true (truthy) value. I'm working on a fix for that but it leads me to think that x-www-form-urlencoded is not the intended way for using the API, so I've made this simple change to use a Newtonsoft serialized JSON as string content instead.

…the non-string values on the side of the API
@avestura
Copy link
Owner

avestura commented Oct 7, 2020

I have found a bug in the Kutt API which results in 'false' or 'False' to be considered a true (truthy) value.

What is this bug you're facing?

@bojidar-danchev
Copy link
Author

bojidar-danchev commented Oct 8, 2020

I have found a bug in the Kutt API which results in 'false' or 'False' to be considered a true (truthy) value.

What is this bug you're facing?

Basically - this:
image

You can see that a request made with 'false' as a URL encoded parameter returns "reuse": true in the response. Hitting the endpoint twice returns the same shortened URL. This works the same way using the C# library and the v2 API.

There is also a secondary issue which happens only with URL encoded calls - the Redis caching of the API actually returns the same single shortened URL even if you call the API with a different target:
image

I made the same request with a different target but the first URL was returned. This is the bigger issue that I want to debug but I haven't been able to properly configure and run the Kutt API in debug mode yet.

You can see in the API source code at line 57 how the reuse which causes a value like 'false' to be considered true, the same with any other non empty string.
Removing the reuse from the request:
image
makes it work as expected.
The same goes for sending a raw body:
image

@avestura
Copy link
Owner

avestura commented Oct 8, 2020

@poeti8 Can you take a look at the above message? It seems x-www-form-urlencoded is not a standard way to talk with the API. Should we take care of this in the client, or it's better to be solved in the server?

@bojidar-danchev
Copy link
Author

bojidar-danchev commented Oct 8, 2020

I've created this pull request for the API which should solve the issues on that side and enable the usage of x-www-form-urlencoded input. I still feel like this should not be the preferred way to use the API as it is likely to cause more issues in the future.

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