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

do not encode with encodeURIComponent if query with method GET passed. #3287

Open
masoudesm opened this issue May 21, 2024 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@masoudesm
Copy link

I have studied the source code and saw this file lib/core/util.js which there is a function called buildURL and it is using node's querystring which by default is doing encodeURIComponent causing a third party backend that I'm calling to be broken, as I can not ask them to change, so preferably, it would be much nicer in undici we can have a option to disable encodeURIComponent or enable it.

@masoudesm masoudesm added the enhancement New feature or request label May 21, 2024
@masoudesm
Copy link
Author

I can do it, if it is possible.

@metcoder95
Copy link
Member

Can you provide an
Minimum Reproducible Example that outlines the behaviour that is leading to the failures?

@masoudesm
Copy link
Author

masoudesm commented May 22, 2024

for example:

API CALL:
import { request, pipeline } from 'undici'; await request('https://jsonplaceholder.typicode.com/comments', { method: 'GET', query: { id: 1, postId: 1, date: '12-10-2024T12:12:40' } })

EXPECTED URL GENERATED:
https://jsonplaceholder.typicode.com/comments?id=1&postId=1&date=12-10-2024T12:12:40

WHAT DEBUG MODE SHOWS:
UNDICI 13726: connecting to jsonplaceholder.typicode.com using https:undefined UNDICI 13726: connected to jsonplaceholder.typicode.com using https:h1 UNDICI 13726: sending request to GET https://jsonplaceholder.typicode.com//comments?id=1&postId=1&date=12-10-2024T12%3A12%3A40 UNDICI 13726: received response to GET https://jsonplaceholder.typicode.com//comments?id=1&postId=1&date=12-10-2024T12%3A12%3A40 - HTTP 200 UNDICI 13726: trailers received from GET https://jsonplaceholder.typicode.com//comments?id=1&postId=1&date=12-10-2024T12%3A12%3A40

HOW TO RUN:
NODE_DEBUG=undici node client.js

as you see it is encoded, this example will work but some server rest implementation (which I would call them bad designed) they don't accept encodedURIComponent in the query string.

@ronag
Copy link
Member

ronag commented May 22, 2024

If you build the whole url yourself and don't use query you should already be able to do this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants