Skip to content

HttpClient: send AddVariable params as query string on GETs and read them on the server#1107

Merged
iroqueta merged 1 commit intomasterfrom
fix/httpclient-get-variables-querystring
Apr 30, 2026
Merged

HttpClient: send AddVariable params as query string on GETs and read them on the server#1107
iroqueta merged 1 commit intomasterfrom
fix/httpclient-get-variables-querystring

Conversation

@iroqueta
Copy link
Copy Markdown
Collaborator

@iroqueta iroqueta commented Apr 29, 2026

Summary

Two related fixes for AddVariable usage on GET requests.

Client side (HttpClientJavaLib + GXHttpClient)

On GET, variables added with AddVariable were serialized as a multipart body. Servers, proxies and CDNs ignore the body of a GET so the values never reached the destination. They now go to the URL query string, URL-encoded in UTF-8.

POST/PUT/DELETE keep using the body as before.

Server side (HttpContextWeb)

HttpRequest.GetVariable() consulted only the request body. On a GET this body is empty so values sent via the query string were invisible. Now, only on GET, if the body parsed empty we fall back to the query string.

POST and any other verb are unchanged: the body still has precedence and the query string is not consulted.

Compatibility

Case Before After
Client: GET with AddVariable Variables in multipart body (ignored by servers) Variables in ?k=v URL
Client: POST with AddVariable Multipart body Unchanged
Server: GET with ?k=v, empty body GetVariable() returns "" Returns the query-string value
Server: GET with body urlencoded (rare) Returns body value Unchanged (body has precedence)
Server: POST with body urlencoded Returns body value Unchanged
Server: POST with ?k=v and body Returns body value (QS ignored) Unchanged

Test plan

  • In GeneXus, run a proc that does &httpClient.AddVariable("PEPE","HOLA") + Execute("GET", url) and verify in org.apache.http.wire that the URL is url?PEPE=HOLA with no body.
  • Run the same with POST and confirm the multipart body is unchanged.
  • Call an HTTP proc with ?PEPE=HOLA from a browser and confirm &HttpRequest.GetVariable("PEPE", &v) returns HOLA.
  • Send a POST with form-urlencoded body to an HTTP proc and confirm GetVariable keeps reading from the body.

Issue: 208539

…them on the server

Two related fixes for AddVariable usage on GET requests.

Client side (HttpClientJavaLib + GXHttpClient):
On GET, variables added with AddVariable were serialized as a multipart
body. Servers, proxies and CDNs ignore the body of a GET so the values
never reached the destination. They now go to the URL query string,
URL-encoded in UTF-8. POST/PUT/DELETE keep using the body as before.

Server side (HttpContextWeb):
HttpRequest.GetVariable() consulted only the request body. On a GET
this body is empty so values sent via the query string were invisible.
Now, only on GET, if the body parsed empty we fall back to the query
string. POST and any other verb are unchanged: the body still has
precedence and the query string is not consulted.
@genexusbot
Copy link
Copy Markdown
Collaborator

Cherry pick to beta failed, 1 conflicted file in commit 85180bc
  • common/src/main/java/com/genexus/internet/GXHttpClient.java

@genexusbot
Copy link
Copy Markdown
Collaborator

Manual cherry pick to beta success

@iroqueta iroqueta merged commit d6bc919 into master Apr 30, 2026
17 of 18 checks passed
@iroqueta iroqueta deleted the fix/httpclient-get-variables-querystring branch April 30, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants