Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ settings.xml
*.ipr
*.idea
run-tests.sh
.github
.junie
.claude
.vscode
6 changes: 2 additions & 4 deletions box.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@
"url":"https://github.com/framework-one/fw1/graphs/contributors"
}
],
"ignore":[

],
"ignore":[],
"devDependencies":{
"testbox":"2.5.0+107"
},
"installPaths":{
"testbox":"testbox"
"testbox":"testbox/"
},
"testbox":{
"runner":"http://localhost:8500/tests/runner.cfm"
Expand Down
9 changes: 9 additions & 0 deletions examples/rest/controllers/main.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ component {
return this;
}

function get( struct rc, struct headers ) {
var response = {
"method": "GET",
"multi": rc.multi,
"single": rc.single
};
variables.fw.renderData().type( 'json' ).data( response );
}

function patch( struct rc, struct headers ) {
var response = {
"method": "PATCH",
Expand Down
2 changes: 1 addition & 1 deletion server.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"app":{
"cfengine":"lucee@5"
"cfengine":"lucee@6"
},
"web":{
"http":{
Expand Down
35 changes: 28 additions & 7 deletions tests/rest/DecodeTest.cfc
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
component extends="mxunit.framework.TestCase" {

function testURLEncodedRequestDecodesMultiField() {
var actual = doURLEncodedHTTPRequest( "GET" );
assertEquals( "GET", actual.method );
assertEquals( "a,b,c", actual.single );
assertEquals( "1,2,3,40,50", actual.multi );
}

function testPostFormEncodedRequestDecodesMultiField() {
var actual = doFormEncodedHTTPRequest( "POST" );
assertEquals( "POST", actual.method );
Expand Down Expand Up @@ -47,19 +54,33 @@ component extends="mxunit.framework.TestCase" {
private function doFormEncodedHTTPRequest( verb ) {
return doHTTPRequest( verb, "application/x-www-form-urlencoded", "multi=1%2C2%2C3&multi=40&multi=50&single=a%2Cb%2Cc" );
}

private function doURLEncodedHTTPRequest( verb ) {
return doHTTPRequest( verb, "application/x-www-form-urlencoded", "&multi=1%2C2%2C3&multi=40&multi=50&single=a%2Cb%2Cc" );
}

private function doJSONEncodedHTTPRequest( verb ) {
return doHTTPRequest( verb, "application/json", '{"multi": "1,2,3,40,50","single": "a,b,c"}' );
}

private function doHTTPRequest( verb, contentType, body ) {
var httpService = new http();
httpService.setmethod( verb );
httpService.setCharset( "utf-8" );
httpService.setUrl( "http://#CGI.SERVER_NAME#:#CGI.SERVER_PORT#/examples/rest/?action=main.#verb#" );
httpService.addParam( type = "header", name = "content-type", value = contentType );
httpService.addParam( type = "body", value = body );
var response = httpService.send().getPrefix().filecontent;

if (verb eq "GET") {
http method="#verb#" charset="utf-8" url="http://#CGI.SERVER_NAME#:#CGI.SERVER_PORT#/examples/rest/" result="httpResult" {
httpparam type="url" name="action" value="main.#verb#";
httpparam type="url" name="multi" value="1,2,3";
httpparam type="url" name="multi" value="40";
httpparam type="url" name="multi" value="50";
httpparam type="url" name="single" value="a,b,c";
}
} else {
http method="#verb#" charset="utf-8" url="http://#CGI.SERVER_NAME#:#CGI.SERVER_PORT#/examples/rest/?action=main.#verb#" result="httpResult" {
httpparam type="header" name="content-type" value="#contentType#";
httpparam type="body" value="#body#";
}
}

var response = httpResult.filecontent;
if ( isJson( response ) ) {
return deserializeJSON( response );
}
Expand Down