Skip to content

Commit dc6c278

Browse files
committed
COLDBOX-1311 #resolve
Remove direct calls to the servlet response.setStatus( int, String ) methods due to jakarta removing statusText
1 parent 6afbca1 commit dc6c278

File tree

14 files changed

+34
-102
lines changed

14 files changed

+34
-102
lines changed

system/Bootstrap.cfc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ component serializable="false" accessors="true" {
354354
contentType : !isNull( renderData.contentType ) ? renderData.contentType : getPageContextResponse().getContentType(),
355355
encoding : "UTF-8",
356356
statusCode : getPageContextResponse().getStatus(),
357-
statusText : "",
358357
isBinary : false,
359358
responseHeaders : event.getResponseHeaders()
360359
};
@@ -492,7 +491,7 @@ component serializable="false" accessors="true" {
492491
else if ( isBoolean( variables.COLDBOX_FAIL_FAST ) && variables.COLDBOX_FAIL_FAST ) {
493492
writeOutput( "Oops! Seems ColdBox is still not ready to serve requests, please try again." );
494493
// You don't have to return a 500, I just did this so JMeter would report it differently than a 200
495-
cfheader( statusCode = "503", statustext = "ColdBox Not Available Yet!" );
494+
cfheader( statusCode = "503" );
496495
// Break up!
497496
return false;
498497
}
@@ -707,14 +706,12 @@ component serializable="false" accessors="true" {
707706
*
708707
* @controller The ColdBox controller
709708
* @statusCode The status code to send
710-
* @statusText The status text to send
711709
* @contentType The content type to send
712710
* @encoding The content encoding
713711
*/
714712
private Bootstrap function renderDataSetup(
715713
required controller,
716714
required statusCode,
717-
required statusText,
718715
required contentType,
719716
required encoding
720717
){

system/RestHandler.cfc

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ component extends="EventHandler" {
135135
data = responseData,
136136
contentType = arguments.prc.response.getContentType(),
137137
statusCode = arguments.prc.response.getStatusCode(),
138-
statusText = arguments.prc.response.getStatusText(),
139138
location = arguments.prc.response.getLocation(),
140139
isBinary = arguments.prc.response.getBinary(),
141140
jsonCallback = arguments.prc.response.getJsonCallback()
@@ -203,8 +202,7 @@ component extends="EventHandler" {
203202
.setError( true )
204203
.setData( {} )
205204
.addMessage( "Base Handler Application Error: #arguments.exception.message#" )
206-
.setStatusCode( arguments.event.STATUS.INTERNAL_ERROR )
207-
.setStatusText( "General application error" );
205+
.setStatusCode( arguments.event.STATUS.INTERNAL_ERROR );
208206

209207
// Development additions Great for Testing
210208
if ( inDebugMode() ) {
@@ -222,7 +220,6 @@ component extends="EventHandler" {
222220
data = prc.response.getDataPacket( reset = this.resetDataOnError ),
223221
contentType = prc.response.getContentType(),
224222
statusCode = prc.response.getStatusCode(),
225-
statusText = prc.response.getStatusText(),
226223
location = prc.response.getLocation(),
227224
isBinary = prc.response.getBinary()
228225
);
@@ -255,16 +252,14 @@ component extends="EventHandler" {
255252
isJSON( arguments.exception.extendedInfo ) ? deserializeJSON( arguments.exception.extendedInfo ) : ""
256253
)
257254
.addMessage( "Validation exceptions occurred, please see the data" )
258-
.setStatusCode( arguments.event.STATUS.BAD_REQUEST )
259-
.setStatusText( "Invalid Request" );
255+
.setStatusCode( arguments.event.STATUS.BAD_REQUEST );
260256

261257
// Render Error Out
262258
arguments.event.renderData(
263259
type = arguments.prc.response.getFormat(),
264260
data = arguments.prc.response.getDataPacket( reset = this.resetDataOnError ),
265261
contentType = arguments.prc.response.getContentType(),
266262
statusCode = arguments.prc.response.getStatusCode(),
267-
statusText = arguments.prc.response.getStatusText(),
268263
location = arguments.prc.response.getLocation(),
269264
isBinary = arguments.prc.response.getBinary()
270265
);
@@ -301,16 +296,14 @@ component extends="EventHandler" {
301296
.addMessage(
302297
len( exception.message ) ? exception.message : "The record you requested cannot be found in this system"
303298
)
304-
.setStatusCode( arguments.event.STATUS.NOT_FOUND )
305-
.setStatusText( "Not Found" );
299+
.setStatusCode( arguments.event.STATUS.NOT_FOUND );
306300

307301
// Render Error Out
308302
arguments.event.renderData(
309303
type = arguments.prc.response.getFormat(),
310304
data = arguments.prc.response.getDataPacket( reset = this.resetDataOnError ),
311305
contentType = arguments.prc.response.getContentType(),
312306
statusCode = arguments.prc.response.getStatusCode(),
313-
statusText = arguments.prc.response.getStatusText(),
314307
location = arguments.prc.response.getLocation(),
315308
isBinary = arguments.prc.response.getBinary()
316309
);
@@ -339,16 +332,14 @@ component extends="EventHandler" {
339332
.addMessage(
340333
"InvalidHTTPMethod Execution of (#arguments.faultAction#): #arguments.event.getHTTPMethod()#"
341334
)
342-
.setStatusCode( arguments.event.STATUS.NOT_ALLOWED )
343-
.setStatusText( "Invalid HTTP Method" );
335+
.setStatusCode( arguments.event.STATUS.NOT_ALLOWED );
344336

345337
// Render Error Out
346338
arguments.event.renderData(
347339
type = arguments.prc.response.getFormat(),
348340
data = arguments.prc.response.getDataPacket( reset = this.resetDataOnError ),
349341
contentType = arguments.prc.response.getContentType(),
350342
statusCode = arguments.prc.response.getStatusCode(),
351-
statusText = arguments.prc.response.getStatusText(),
352343
location = arguments.prc.response.getLocation(),
353344
isBinary = arguments.prc.response.getBinary()
354345
);
@@ -369,16 +360,14 @@ component extends="EventHandler" {
369360
.getResponse()
370361
.setError( true )
371362
.addMessage( "Action '#arguments.missingAction#' could not be found" )
372-
.setStatusCode( arguments.event.STATUS.NOT_FOUND )
373-
.setStatusText( "Invalid Action" );
363+
.setStatusCode( arguments.event.STATUS.NOT_FOUND );
374364

375365
// Render Error Out
376366
arguments.event.renderData(
377367
type = arguments.prc.response.getFormat(),
378368
data = arguments.prc.response.getDataPacket( reset = this.resetDataOnError ),
379369
contentType = arguments.prc.response.getContentType(),
380370
statusCode = arguments.prc.response.getStatusCode(),
381-
statusText = arguments.prc.response.getStatusText(),
382371
location = arguments.prc.response.getLocation(),
383372
isBinary = arguments.prc.response.getBinary()
384373
);
@@ -422,7 +411,6 @@ component extends="EventHandler" {
422411
.getResponse()
423412
.setError( true )
424413
.setStatusCode( arguments.event.STATUS.NOT_AUTHENTICATED )
425-
.setStatusText( "Expired Authentication Credentials" )
426414
.addMessage( "Expired Authentication Credentials" );
427415
return;
428416
}
@@ -431,7 +419,6 @@ component extends="EventHandler" {
431419
.getResponse()
432420
.setError( true )
433421
.setStatusCode( arguments.event.STATUS.NOT_AUTHENTICATED )
434-
.setStatusText( "Invalid or Missing Credentials" )
435422
.addMessage( "Invalid or Missing Authentication Credentials" );
436423

437424
/**
@@ -440,8 +427,7 @@ component extends="EventHandler" {
440427
if ( arguments.abort ) {
441428
event.setHTTPHeader( name = "Content-Type", value = "application/json" );
442429
event.setHTTPHeader(
443-
statusCode = "#arguments.event.STATUS.NOT_AUTHENTICATED#",
444-
statusText = "Invalid or Missing Credentials"
430+
statusCode = "#arguments.event.STATUS.NOT_AUTHENTICATED#"
445431
);
446432

447433
writeOutput( toJson( prc.response.getDataPacket( reset = this.resetDataOnError ) ) );
@@ -482,7 +468,6 @@ component extends="EventHandler" {
482468
.getResponse()
483469
.setError( true )
484470
.setStatusCode( arguments.event.STATUS.NOT_AUTHORIZED )
485-
.setStatusText( "Unauthorized Resource" )
486471
.addMessage( "You are not allowed to access this resource" );
487472

488473
// Check for validator results
@@ -496,8 +481,7 @@ component extends="EventHandler" {
496481
if ( arguments.abort ) {
497482
event.setHTTPHeader( name = "Content-Type", value = "application/json" );
498483
event.setHTTPHeader(
499-
statusCode = "#arguments.event.STATUS.NOT_AUTHORIZED#",
500-
statusText = "Not Authorized"
484+
statusCode = "#arguments.event.STATUS.NOT_AUTHORIZED#"
501485
);
502486

503487
writeOutput( serializeJSON( prc.response.getDataPacket( reset = this.resetDataOnError ) ) );
@@ -527,7 +511,6 @@ component extends="EventHandler" {
527511
.getResponse()
528512
.setError( true )
529513
.setStatusCode( arguments.event.STATUS.NOT_FOUND )
530-
.setStatusText( "Not Found" )
531514
.addMessage( "The resource requested (#event.getCurrentRoutedURL()#) could not be found" );
532515
}
533516

@@ -586,8 +569,7 @@ component extends="EventHandler" {
586569
} : {}
587570
)
588571
.addMessage( "An exception ocurred: #arguments.exception.message#" )
589-
.setStatusCode( arguments.event.STATUS.INTERNAL_ERROR )
590-
.setStatusText( "General application error" );
572+
.setStatusCode( arguments.event.STATUS.INTERNAL_ERROR );
591573
}
592574

593575
/**
@@ -613,7 +595,6 @@ component extends="EventHandler" {
613595
.getResponse()
614596
.setError( true )
615597
.setStatusCode( arguments.event.STATUS.EXPECTATION_FAILED )
616-
.setStatusText( "Expectation Failed" )
617598
.addMessage( arguments.message );
618599
}
619600

system/testing/mock/web/context/MockRequestContext.cfc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ component
1616
* return RequestContext
1717
*
1818
* @statusCode.hint the status code
19-
* @statusText.hint the status text
2019
* @name.hint The header name
2120
* @value.hint The header value
2221
* @charset.hint The charset to use, defaults to UTF-8
@@ -25,7 +24,6 @@ component
2524
// status code?
2625
if ( !isNull( arguments.statusCode ) ) {
2726
setStatusCode( arguments.statusCode );
28-
setStatusText( arguments.statusText );
2927
}
3028
// Name Exists
3129
else if ( structKeyExists( arguments, "name" ) ) {

system/web/Controller.cfc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,7 @@ component serializable="false" accessors="true" {
848848
)
849849
) {
850850
oRequestContext.setHTTPHeader(
851-
statusCode = 405,
852-
statusText = "Invalid HTTP Method: '#oRequestContext.getHTTPMethod()#'"
851+
statusCode = 405
853852
);
854853
// set Invalid HTTP method in context
855854
oRequestContext.setIsInvalidHTTPMethod();
@@ -899,8 +898,7 @@ component serializable="false" accessors="true" {
899898

900899
// Throw Exception, no handlers defined
901900
oRequestContext.setHTTPHeader(
902-
statusCode = 405,
903-
statusText = "Invalid HTTP Method: '#oRequestContext.getHTTPMethod()#'"
901+
statusCode = 405
904902
);
905903
throw(
906904
message = "Invalid HTTP Method: '#oRequestContext.getHTTPMethod()#'",

system/web/context/RequestContext.cfc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ component serializable="false" accessors="true" {
101101

102102
/**
103103
* The last status text
104+
* @REMOVED by Jakarta EE, remove by 8
104105
*/
105106
property
106107
name ="statusText"
@@ -141,6 +142,7 @@ component serializable="false" accessors="true" {
141142
};
142143

143144
// HTTP STATUS TEXTS
145+
// TODO: REMOVE BY 8
144146
this.STATUS_TEXTS = {
145147
"100" : "Continue",
146148
"101" : "Switching Protocols",

system/web/context/Response.cfc

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@ component accessors="true" {
8282
type ="numeric"
8383
default="200";
8484

85-
/**
86-
* The status text of the response
87-
*/
88-
property
89-
name ="statusText"
90-
type ="string"
91-
default="OK";
92-
9385
/**
9486
* The response time
9587
*/
@@ -106,6 +98,7 @@ component accessors="true" {
10698
/**
10799
* Helper Status Texts Lookups
108100
*/
101+
// TODO: REMOVE BY 8
109102
this.STATUS_TEXTS = {
110103
"100" : "Continue",
111104
"101" : "Switching Protocols",
@@ -186,7 +179,6 @@ component accessors="true" {
186179
variables.jsonCallBack = "";
187180
variables.contentType = "";
188181
variables.statusCode = 200;
189-
variables.statusText = "OK";
190182
variables.responsetime = 0;
191183
variables.headers = [];
192184

@@ -288,20 +280,14 @@ component accessors="true" {
288280
}
289281

290282
/**
291-
* Sets the status code with a statusText for the API response
283+
* Sets the status code for the API response
292284
*
293285
* @code The status code to be set
294-
* @text The status text to be set
295286
*
296287
* @return Returns the Response object for chaining
297288
*/
298-
Response function setStatus( required code, text ){
299-
if ( isNull( arguments.text ) OR !len( arguments.text ) ) {
300-
arguments.text = this.STATUS_TEXTS[ arguments.code ] ?: "";
301-
}
302-
289+
Response function setStatus( required code ){
303290
variables.statusCode = arguments.code;
304-
variables.statusText = arguments.text;
305291
return this;
306292
}
307293

@@ -328,20 +314,18 @@ component accessors="true" {
328314
*
329315
* @errorMessage The error message to set
330316
* @statusCode The status code to set, if any
331-
* @statusText The status text to set, if any
332317
*
333318
* @return Returns the Response object for chaining
334319
*/
335320
Response function setErrorMessage(
336321
required errorMessage,
337-
statusCode,
338-
statusText = ""
322+
statusCode
339323
){
340324
setError( true );
341325
addMessage( arguments.errorMessage );
342326

343327
if ( !isNull( arguments.statusCode ) ) {
344-
setStatus( arguments.statusCode, arguments.statusText );
328+
setStatus( arguments.statusCode );
345329
}
346330

347331
return this;

system/web/routing/Router.cfc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ component
2222
****************************************************************/
2323

2424
property
25-
name ="cachebox"
25+
name ="cachebox"
2626
inject ="cachebox"
2727
delegate="getCache";
2828
property
2929
name ="controller"
30-
inject ="coldbox"
30+
inject ="coldbox"
3131
delegate="relocate,runEvent,runRoute";
3232
property name="flash" inject="coldbox:flash";
3333
property name="logBox" inject="logbox";
@@ -822,7 +822,6 @@ component
822822
* @append Whether the route should be appended or pre-pended to the array. By default we append to the end of the array
823823
* @response An HTML response string to send back or a closure to be executed that should return the response. The closure takes in a 'params' struct of all matched params and the string will be parsed with the named value pairs as ${param}
824824
* @statusCode The HTTP status code to send to the browser response.
825-
* @statusText Explains the HTTP status code sent to the browser response.
826825
* @condition A closure or UDF to execute that MUST return true to use route if matched or false and continue.
827826
* @name The name of the route
828827
* @domain The domain to match, including wildcards
@@ -857,7 +856,6 @@ component
857856
boolean append = "true",
858857
any response = "",
859858
numeric statusCode = 200,
860-
string statusText = "",
861859
any condition = "",
862860
string name = "",
863861
string domain = "",
@@ -1243,7 +1241,6 @@ component
12431241
"response" : "", // Do we have an inline response closure
12441242
"ssl" : false, // Are we forcing SSL
12451243
"statusCode" : 200, // The response status code
1246-
"statusText" : "Ok", // The response status text
12471244
"valuePairTranslation" : true, // If we translate name-value pairs in the URL by convention
12481245
"verbs" : "", // The HTTP Verbs allowed
12491246
"view" : "", // The view to proxy to
@@ -1967,14 +1964,12 @@ component
19671964
*
19681965
* @body The body of the response a lambda or closure
19691966
* @statusCode The status code to use, defaults to 200
1970-
* @statusText The status text to use, defaults to 'OK'
19711967
*
19721968
* @throws InvalidArgumentException
19731969
*/
19741970
function toResponse(
19751971
required body,
1976-
numeric statusCode = 200,
1977-
statusText = "Ok"
1972+
numeric statusCode = 200
19781973
){
19791974
// Arg Check
19801975
if ( !isClosure( arguments.body ) && !isCustomFunction( arguments.body ) && !isSimpleValue( arguments.body ) ) {
@@ -1991,8 +1986,7 @@ component
19911986
variables.thisRoute.append(
19921987
{
19931988
response : arguments.body,
1994-
statusCode : arguments.statusCode,
1995-
statusText : arguments.statusText
1989+
statusCode : arguments.statusCode
19961990
},
19971991
true
19981992
);

0 commit comments

Comments
 (0)