Fixing #355.All of this happens when encode_url=true in setup config. Before this change all query in http://aaa.bbb/ccc?<query> gets encoded. Since plugin's treesitter does not support URLs like http://...?value , this behaviour seems pointless to me.
Besides everything else it spoils = sign, replacing it to %3d. So, at least on my machine, the most basic test
GET https://reqres.in/api/users?page=6
is indifferent to value of page, so you can change it, response will be the same, and it will be the same as if you delete ?page=6 at all.
Some examples how echo server sees current requests with parameters:
Request: GET https://echo.free.beeceptor.com/hi?x=1&y=2&df=привет
Reply:
This fix aims to change this behaviour to more like curl's --data-urlencode works (see manual). This changes behaviour of encoding, so only value in key=value pairs of query will be changed. Currently, this works only with & separator.
This is what I noticed while writing the fix
Firstly, plugin have no tests with more than one query parameter, and no tests to validate if reply corresponds to request.
Secondly, as far as I understood, reading the URL manual, query string is unspecified, so instead of & delimiter it could be ; or any other, so splitting _url:get_query() by & does not cover all possible use cases (despite the fact that the vast majority use the query string as key=value&...). At least, this fix covers following curl's --data-urlencode patterns:
name=content. This fix is all about this use case
content. Not tested, because plugin gives an error when trying to execute http://.../some?value. But i suppose this will work
=content. Same as content, but depends on how _url:set_query() behaves
name@filename and @filename requires additional support, which, as far as I understand, has already been partially implemented, so this doesn't make much sense
Summary. Because of query string is unspecified, and we don't know the rule how to encode it's parts, should we add some option so user can define encoding behaviour. It may be set in config or locally as request parameter (similar to 'host')?
Fixing #355.All of this happens when
encode_url=true
in setup config. Before this change all query inhttp://aaa.bbb/ccc?<query>
gets encoded. Since plugin's treesitter does not support URLs likehttp://...?value
, this behaviour seems pointless to me. Besides everything else it spoils=
sign, replacing it to%3d
. So, at least on my machine, the most basic testis indifferent to value of
page
, so you can change it, response will be the same, and it will be the same as if you delete?page=6
at all.Some examples how
echo server
sees current requests with parameters: Request:GET https://echo.free.beeceptor.com/hi?x=1&y=2&df=привет
Reply:Request:
GET https://echo.free.beeceptor.com/some?a=1
Reply:Comparing to
curl -G https://echo.free.beeceptor.com/some --data-urlencode "x=1" --data-urlencode "y=2" --data-urlencode "hello=привет"
, which givesThis fix aims to change this behaviour to more like curl's
--data-urlencode
works (see manual). This changes behaviour of encoding, so onlyvalue
inkey=value
pairs of query will be changed. Currently, this works only with & separator.This is what I noticed while writing the fix
Firstly, plugin have no tests with more than one query parameter, and no tests to validate if reply corresponds to request.
Secondly, as far as I understood, reading the URL manual, query string is unspecified, so instead of
&
delimiter it could be;
or any other, so splitting_url:get_query()
by&
does not cover all possible use cases (despite the fact that the vast majority use the query string askey=value&...
). At least, this fix covers following curl's--data-urlencode
patterns:name=content
. This fix is all about this use casecontent
. Not tested, because plugin gives an error when trying to executehttp://.../some?value
. But i suppose this will work=content
. Same ascontent
, but depends on how_url:set_query()
behavesname@filename
and@filename
requires additional support, which, as far as I understand, has already been partially implemented, so this doesn't make much senseSummary. Because of query string is unspecified, and we don't know the rule how to encode it's parts, should we add some option so user can define encoding behaviour. It may be set in config or locally as request parameter (similar to 'host')?