Skip to content
Merged
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
2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"shortDescription":"REST Web Service framework for ColdFusion and Lucee",
"slug":"taffy",
"author":"Adam Tuttle",
"version":"3.7.0",
"version":"3.8.0",
"homepage":"https://taffy.io/",
"documentation":"https://docs.taffy.io/",
"type":"mvc",
Expand Down
42 changes: 27 additions & 15 deletions core/api.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<cfset setupFramework() />
<cfset checkEngineSupport() />
<cfset after = getTickCount() />
<cfheader name="X-TIME-TO-RELOAD" value="#(after-before)#" />
<cfset addTaffyHeader("X-TIME-TO-RELOAD", after-before) />
<cfreturn true />
</cffunction>

Expand Down Expand Up @@ -431,19 +431,19 @@
<cfheader name="ALLOW" value="#local.allowVerbs#" />

<!--- metrics headers that should always apply --->
<cfheader name="X-TIME-IN-PARSE" value="#m.parseTime#" />
<cfheader name="X-TIME-IN-ONTAFFYREQUEST" value="#m.otrTime#" />
<cfset addTaffyHeader("X-TIME-IN-PARSE", m.parseTime) />
<cfset addTaffyHeader("X-TIME-IN-ONTAFFYREQUEST", m.otrTime) />
<cfif structKeyExists(m, "resourceTime")>
<cfheader name="X-TIME-IN-RESOURCE" value="#m.resourceTime#" />
<cfset addTaffyHeader("X-TIME-IN-RESOURCE", m.resourceTime) />
</cfif>
<cfif structKeyExists(m, "cacheCheckTime")>
<cfheader name="X-TIME-IN-CACHE-CHECK" value="#m.cacheCheckTime#" />
<cfset addTaffyHeader("X-TIME-IN-CACHE-CHECK", m.cacheCheckTime) />
</cfif>
<cfif structKeyExists(m, "cacheGetTime")>
<cfheader name="X-TIME-IN-CACHE-GET" value="#m.cacheGetTime#" />
<cfset addTaffyHeader("X-TIME-IN-CACHE-GET", m.cacheGetTime) />
</cfif>
<cfif structKeyExists(m, "cacheSaveTime")>
<cfheader name="X-TIME-IN-CACHE-SAVE" value="#m.cacheSaveTime#" />
<cfset addTaffyHeader("X-TIME-IN-CACHE-SAVE", m.cacheSaveTime) />
</cfif>

<cfif application._taffy.settings.exposeHeaders>
Expand Down Expand Up @@ -478,7 +478,7 @@
/>
<cfset _taffyRequest.metrics.afterSerialize = getTickCount() />
<cfset m.serializeTime = m.afterSerialize - m.beforeSerialize />
<cfheader name="X-TIME-IN-SERIALIZE" value="#m.serializeTime#" />
<cfset addTaffyHeader("X-TIME-IN-SERIALIZE", m.serializeTime) />

<!--- apply jsonp wrapper if requested --->
<cfif structKeyExists(_taffyRequest, "jsonpCallback")>
Expand Down Expand Up @@ -514,7 +514,7 @@
<cfif structKeyExists(m, "resourceTime")>
<cfset m.taffyTime -= m.resourceTime />
</cfif>
<cfheader name="X-TIME-IN-TAFFY" value="#m.taffyTime#" />
<cfset addTaffyHeader("X-TIME-IN-TAFFY", m.taffyTime) />

<cfcontent reset="true" type="#application._taffy.settings.mimeExtensions[_taffyRequest.returnMimeExt]#; charset=utf-8" />
<cfif _taffyRequest.resultSerialized neq ('"' & '"')>
Expand All @@ -528,19 +528,19 @@
<cfelseif _taffyRequest.resultType eq "filename">
<cfset m.done = getTickCount() />
<cfset m.taffyTime = m.done - m.init - m.parseTime - m.otrTime - m.resourceTime />
<cfheader name="X-TIME-IN-TAFFY" value="#m.taffyTime#" />
<cfset addTaffyHeader("X-TIME-IN-TAFFY", m.taffyTime) />
<cfcontent reset="true" file="#_taffyRequest.result.getFileName()#" type="#_taffyRequest.result.getFileMime()#" deletefile="#_taffyRequest.result.getDeleteFile()#" />

<cfelseif _taffyRequest.resultType eq "filedata">
<cfset m.done = getTickCount() />
<cfset m.taffyTime = m.done - m.init - m.parseTime - m.otrTime - m.resourceTime />
<cfheader name="X-TIME-IN-TAFFY" value="#m.taffyTime#" />
<cfset addTaffyHeader("X-TIME-IN-TAFFY", m.taffyTime) />
<cfcontent reset="true" variable="#_taffyRequest.result.getFileData()#" type="#_taffyRequest.result.getFileMime()#" />

<cfelseif _taffyRequest.resultType eq "imagedata">
<cfset m.done = getTickCount() />
<cfset m.taffyTime = m.done - m.init - m.parseTime - m.otrTime - m.resourceTime />
<cfheader name="X-TIME-IN-TAFFY" value="#m.taffyTime#" />
<cfset addTaffyHeader("X-TIME-IN-TAFFY", m.taffyTime) />
<cfcontent reset="true" variable="#_taffyRequest.result.getImageData()#" type="#_taffyRequest.result.getFileMime()#" />

</cfif>
Expand Down Expand Up @@ -571,7 +571,7 @@
,_taffyRequest.statusArgs.statusCode
) />
<cfset m.otreTime = getTickCount() - m.beforeOnTaffyRequestEnd />
<cfheader name="X-TIME-IN-ONTAFFYREQUESTEND" value="#m.otreTime#" />
<cfset addTaffyHeader("X-TIME-IN-ONTAFFYREQUESTEND", m.otreTime) />

<cfif len(trim(local.resultSerialized))>
<cfoutput>#local.resultSerialized#</cfoutput>
Expand Down Expand Up @@ -607,10 +607,9 @@
<cffunction name="setupFramework" access="private" output="false" returntype="void">
<cfset var local = structNew() />
<cfparam name="variables.framework" default="#structNew()#" />
<cfheader name="X-TAFFY-RELOADED" value="true" />
<cfset request.taffyReloaded = true />
<cfset local._taffy = structNew() />
<cfset local._taffy.version = "3.7.0" />
<cfset local._taffy.version = "3.8.0" />
<cfset local._taffy.endpoints = structNew() />
<!--- default settings --->
<cfset local.defaultConfig = structNew() />
Expand Down Expand Up @@ -638,6 +637,7 @@
<cfset local.defaultConfig.exposeHeaders = false />
<cfset local.defaultConfig.jsonp = false />
<cfset local.defaultConfig.noDataSends204NoContent = false />
<cfset local.defaultConfig.exposeTaffyHeaders = true />
<cfset local.defaultConfig.globalHeaders = structNew() />
<cfset local.defaultConfig.mimeTypes = structNew() />
<cfset local.defaultConfig.returnExceptionsAsJson = true />
Expand Down Expand Up @@ -717,6 +717,9 @@
<cfset local._taffy.contentTypes = getSupportedContentTypes(local._taffy.settings.deserializer) />
<!--- hot-swap! --->
<cfset application._taffy = local._taffy />

<!--- we must write the header *after* we have initialized our settings --->
<cfset addTaffyHeader("X-TAFFY-RELOADED", true) />
</cffunction>

<cffunction name="parseRequest" access="private" output="false" returnType="struct">
Expand Down Expand Up @@ -1538,4 +1541,13 @@

</cffunction>

<cffunction name="addTaffyHeader">
<cfargument name="name" type="string" required="true" />
<cfargument name="value" type="string" required="true" />

<cfif application._taffy.settings.exposeTaffyHeaders>
<cfheader name="#arguments.name#" value="#arguments.value#" />
</cfif>
</cffunction>

</cfcomponent>
22 changes: 22 additions & 0 deletions docs/@next.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ variables.framework = {

unhandledPaths = "/flex2gateway",
allowCrossDomain = false,
exposeTaffyHeaders = true,
globalHeaders = structNew(),
debugKey = "debug",

Expand Down Expand Up @@ -575,6 +576,27 @@ variables.framework.allowCrossDomain =
"http://example.com; http://foo.bar, http://google.com";
```

#### exposeTaffyHeaders

**Available in:** Taffy 3.8+<br/>
**Type:** Boolean<br/>
**Default:** true<br/>
**Description:** Determines if the standard Taffy debug HTTP response headers should be included with each request. The Taffy debug headers are:

* `X-TAFFY-RELOADED` — Determines if the Taffy configuration was reloaded on the request.
* `X-TIME-TO-RELOAD` — The time it took for Taffy to initialize.
* `X-TIME-IN-PARSE` — The time it took to parse the request.
* `X-TIME-IN-ONTAFFYREQUEST` — The time spent in the `onTaffyRequest` method.
* `X-TIME-IN-RESOURCE` — The time spent executing the requested resource.
* `X-TIME-IN-CACHE-CHECK` — The time spent checking for a cached response.
* `X-TIME-IN-CACHE-GET` — The time spent to retrieve a cached response.
* `X-TIME-IN-CACHE-SAVE` — The time spent to save a cached response.
* `X-TIME-IN-SERIALIZE` — The time spent serializing the response.
* `X-TIME-IN-TAFFY` — The time spent executing the Taffy internals.
* `X-TIME-IN-ONTAFFYREQUESTEND` — The time spent in the `onTaffyRequestEnd` method.

Setting this to `false` will prevent these response headers from being written to the HTTP stream.

#### globalHeaders

**Available in:** Taffy 1.2+<br/>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cfml-taffy",
"version": "3.7.0",
"version": "3.8.0",
"author": "Adam Tuttle <adamtuttlecodes@gmail.com>",
"license": "MIT",
"homepage": "https://taffy.io",
Expand Down
1 change: 1 addition & 0 deletions tests/Application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
variables.framework.globalHeaders = {};
variables.framework.globalHeaders["x-foo-globalheader"] = "snafu";
variables.framework.exposeHeaders = true;
variables.framework.exposeTaffyHeaders = true;

variables.framework.environments = {};
variables.framework.environments.test = {};
Expand Down