Skip to content

Commit c7cf713

Browse files
authored
feat: Add withoutEncodingUrl flag
Both ACF and Lucee automatically encode the url passed to CFHTTP. This is less than desirable since it encodes valid url characters such as a colon (`:`). In Lucee, we can skip this automatic encoding using the `encodeurl` flag. There is no such flag in ACF. This change adds a flag in the `HyperRequest` called `encodeUrl` which is set to `true` by default. If it is `true` when sending the request, nothing will be added to the attribute struct. If it is `false`, it will be added to the attribute struct passed to `cfhttp`. This will cause an error in ACF, but there's really not much of a workaround right now.
1 parent 65b7f47 commit c7cf713

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,15 @@ A convenience method to not follow any redirects.
265265
| ------------ | ---- | -------- | ------- | ----------- |
266266
| No arguments | | | | |
267267

268+
##### `withoutEncodingUrl`
269+
270+
A convenience method to not encode the url.
271+
WARNING: Not supported on Adobe engines.
272+
273+
| Name | Type | Required | Default | Description |
274+
| ------------ | ---- | -------- | ------- | ----------- |
275+
| No arguments | | | | |
276+
268277
##### `getMaximumRedirects`
269278

270279
Gets the maximum number of redirects to follow.

models/CfhttpHttpClient.cfc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ component implements="HyperHttpClientInterface" {
4040
"resolveURL" : req.getResolveUrls()
4141
};
4242

43+
if ( !req.getEncodeUrl() ) {
44+
attrCollection[ "encodeurl" ] = false;
45+
}
46+
4347
if ( len( req.getUsername() ) ) {
4448
attrCollection[ "username" ] = req.getUsername();
4549
}

models/HyperRequest.cfc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ component accessors="true" {
2727
*/
2828
property name="resolveUrls" default="false";
2929

30+
/**
31+
* Setting this to false will not automatically encode the url passed.
32+
* WARNING: Setting this to false is not supported on Adobe engines.
33+
*/
34+
property name="encodeUrl" default="true";
35+
3036
/**
3137
* The HTTP method for the request.
3238
*/
@@ -370,6 +376,16 @@ component accessors="true" {
370376
return this;
371377
}
372378

379+
/**
380+
* A convenience method to not encode the url.
381+
*
382+
* @returns The HyperRequest instance.
383+
*/
384+
function withoutEncodingUrl() {
385+
setEncodeUrl( false );
386+
return this;
387+
}
388+
373389
/**
374390
* A convenience method to not throw on errors.
375391
*

0 commit comments

Comments
 (0)