-
Notifications
You must be signed in to change notification settings - Fork 117
CF2025: Removing deprecated cfheader StatusText attribute #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rlorenzo
wants to merge
3
commits into
atuttle:main
Choose a base branch
from
rlorenzo:statustext-deprecation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <!--- | ||
| Global utility function wrapper for backwards compatible cfheader handling. | ||
|
|
||
| This provides a simple function interface that wraps the cfHeaderUtils.cfc component. | ||
| The CFC is cached in application scope for performance. This helper allows code to call | ||
| setTaffyStatusHeader() directly without managing component instances. | ||
| ---> | ||
|
|
||
| <cffunction name="setTaffyStatusHeader" output="false" returntype="void" hint="Sets HTTP status header with backwards compatibility for CF 2025"> | ||
| <cfargument name="statusCode" type="numeric" required="true" hint="HTTP status code to set" /> | ||
| <cfargument name="statusText" type="string" required="false" default="" hint="HTTP status text (optional for CF 2025+)" /> | ||
|
|
||
| <cfscript> | ||
| // Ensure thread-safe initialization using an exclusive application-scoped lock | ||
| if (!structKeyExists(application, "_taffyHeaderUtils")) { | ||
| lock name="taffyHeaderUtilsInit" scope="application" type="exclusive" timeout="5" { | ||
| // Double-check inside the lock to prevent race conditions | ||
| if (!structKeyExists(application, "_taffyHeaderUtils")) { | ||
| application._taffyHeaderUtils = createObject("component", "taffy.core.cfHeaderUtils").init(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| application._taffyHeaderUtils.setStatusHeader(arguments.statusCode, arguments.statusText); | ||
| </cfscript> | ||
| </cffunction> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| <!--- | ||
| Core component class for backwards compatible HTTP status header handling for ColdFusion 2025+ | ||
| where the statustext attribute has been deprecated. | ||
|
|
||
| This CFC provides the structured, testable implementation with dependency injection support. | ||
| For a simple global function interface, see cfHeaderHelper.cfm which wraps this component. | ||
| ---> | ||
| <cfcomponent hint="Utility component for backwards compatible cfheader handling"> | ||
|
|
||
| <!--- Cache the CF version check since it won't change during execution ---> | ||
| <cfset variables.isCF2025OrLater = "" /> | ||
| <cfset variables.serverInfo = "" /> | ||
|
|
||
| <!--- Constructor to inject server information ---> | ||
| <cffunction name="init" access="public" output="false" returntype="any" hint="Constructor with optional server info injection"> | ||
| <cfargument name="serverInfo" type="struct" required="false" default="#structNew()#" hint="Server info for testing/injection" /> | ||
|
|
||
| <cfscript> | ||
| if (structIsEmpty(arguments.serverInfo)) { | ||
| // Only reference server scope if no injection provided | ||
| variables.serverInfo = server; | ||
| } else { | ||
| variables.serverInfo = arguments.serverInfo; | ||
| } | ||
| </cfscript> | ||
|
|
||
| <cfreturn this /> | ||
| </cffunction> | ||
|
|
||
| <cffunction name="setStatusHeader" access="public" output="false" returntype="void" hint="Sets HTTP status header with backwards compatibility for CF 2025"> | ||
| <cfargument name="statusCode" type="numeric" required="true" hint="HTTP status code to set" /> | ||
| <cfargument name="statusText" type="string" required="false" default="" hint="HTTP status text (optional for CF 2025+)" /> | ||
|
|
||
| <cfscript> | ||
| if (isColdFusion2025OrLater()) { | ||
| cfheader(statuscode=arguments.statusCode); | ||
| } else { | ||
| if (len(arguments.statusText)) { | ||
| cfheader(statuscode=arguments.statusCode, statustext=arguments.statusText); | ||
| } else { | ||
| cfheader(statuscode=arguments.statusCode); | ||
| } | ||
| } | ||
| </cfscript> | ||
| </cffunction> | ||
|
|
||
| <cffunction name="isColdFusion2025OrLater" access="public" output="false" returntype="boolean" hint="Detects if running ColdFusion 2025 or later"> | ||
| <cfscript> | ||
| // Cache the result since CF version won't change during execution | ||
| if (variables.isCF2025OrLater == "") { | ||
| var cfVersion = 0; | ||
| if (structKeyExists(variables.serverInfo, "coldfusion") && | ||
| structKeyExists(variables.serverInfo.coldfusion, "productname") && | ||
| variables.serverInfo.coldfusion.productname contains "ColdFusion") { | ||
rlorenzo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Extract the first number from the productversion string, regardless of format | ||
| var versionMatch = reMatch("\d+", variables.serverInfo.coldfusion.productversion); | ||
rlorenzo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (arrayLen(versionMatch) > 0) { | ||
| cfVersion = val(versionMatch[1]); | ||
| } else { | ||
| cfVersion = 0; | ||
| } | ||
| } | ||
| variables.isCF2025OrLater = (cfVersion >= 2025); | ||
| } | ||
| return variables.isCF2025OrLater; | ||
| </cfscript> | ||
| </cffunction> | ||
|
|
||
| </cfcomponent> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.