Skip to content
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

Add suppressTaffyHeaders settings #439

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
73 changes: 52 additions & 21 deletions core/api.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
<cfset var after = 0 />
<cfset setupFramework() />
<cfset after = getTickCount() />
<cfheader name="X-TIME-TO-RELOAD" value="#(after-before)#" />
<cfif not application._taffy.settings.suppressTaffyHeaders >
<cfheader name="X-TIME-TO-RELOAD" value="#(after-before)#" />
</cfif>
<cfreturn true />
</cffunction>

Expand Down Expand Up @@ -430,19 +432,21 @@
<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#" />
<cfif structKeyExists(m, "resourceTime")>
<cfheader name="X-TIME-IN-RESOURCE" value="#m.resourceTime#" />
</cfif>
<cfif structKeyExists(m, "cacheCheckTime")>
<cfheader name="X-TIME-IN-CACHE-CHECK" value="#m.cacheCheckTime#" />
</cfif>
<cfif structKeyExists(m, "cacheGetTime")>
<cfheader name="X-TIME-IN-CACHE-GET" value="#m.cacheGetTime#" />
</cfif>
<cfif structKeyExists(m, "cacheSaveTime")>
<cfheader name="X-TIME-IN-CACHE-SAVE" value="#m.cacheSaveTime#" />
<cfif not application._taffy.settings.suppressTaffyHeaders >
<cfheader name="X-TIME-IN-PARSE" value="#m.parseTime#" />
<cfheader name="X-TIME-IN-ONTAFFYREQUEST" value="#m.otrTime#" />
<cfif structKeyExists(m, "resourceTime")>
<cfheader name="X-TIME-IN-RESOURCE" value="#m.resourceTime#" />
</cfif>
<cfif structKeyExists(m, "cacheCheckTime")>
<cfheader name="X-TIME-IN-CACHE-CHECK" value="#m.cacheCheckTime#" />
</cfif>
<cfif structKeyExists(m, "cacheGetTime")>
<cfheader name="X-TIME-IN-CACHE-GET" value="#m.cacheGetTime#" />
</cfif>
<cfif structKeyExists(m, "cacheSaveTime")>
<cfheader name="X-TIME-IN-CACHE-SAVE" value="#m.cacheSaveTime#" />
</cfif>
</cfif>

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

<cfif not application._taffy.settings.suppressTaffyHeaders >
<cfheader name="X-TIME-IN-SERIALIZE" value="#m.serializeTime#" />
</cfif>

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

<cfif not application._taffy.settings.suppressTaffyHeaders >
<cfheader name="X-TIME-IN-TAFFY" value="#m.taffyTime#" />
</cfif>

<cfcontent reset="true" type="#application._taffy.settings.mimeExtensions[_taffyRequest.returnMimeExt]#; charset=utf-8" />
<cfif _taffyRequest.resultSerialized neq ('"' & '"')>
Expand All @@ -527,19 +537,32 @@
<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#" />

<cfif not application._taffy.settings.suppressTaffyHeaders >
<cfheader name="X-TIME-IN-TAFFY" value="#m.taffyTime#" />
</cfif>

<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#" />


<cfif not application._taffy.settings.suppressTaffyHeaders >
<cfheader name="X-TIME-IN-TAFFY" value="#m.taffyTime#" />
</cfif>

<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#" />

<cfif not application._taffy.settings.suppressTaffyHeaders >
<cfheader name="X-TIME-IN-TAFFY" value="#m.taffyTime#" />
</cfif>

<cfcontent reset="true" variable="#_taffyRequest.result.getImageData()#" type="#_taffyRequest.result.getFileMime()#" />

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

<cfif not application._taffy.settings.suppressTaffyHeaders >
<cfheader name="X-TIME-IN-ONTAFFYREQUESTEND" value="#m.otreTime#" />
</cfif>

<cfif len(trim(local.resultSerialized))>
<cfoutput>#local.resultSerialized#</cfoutput>
Expand All @@ -590,7 +616,7 @@
<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.6.0" />
Expand All @@ -606,6 +632,7 @@
<cfset local.defaultConfig.reloadKey = "reload" />
<cfset local.defaultConfig.reloadPassword = "true" />
<cfset local.defaultConfig.reloadOnEveryRequest = false />
<cfset local.defaultConfig.suppressTaffyHeaders = false />
<cfset local.defaultConfig.simulateKey = "sampleResponse" />
<cfset local.defaultConfig.simulatePassword = "true" />
<cfset local.defaultConfig.endpointURLParam = 'endpoint' />
Expand Down Expand Up @@ -700,6 +727,10 @@
<cfset local._taffy.contentTypes = getSupportedContentTypes(local._taffy.settings.deserializer) />
<!--- hot-swap! --->
<cfset application._taffy = local._taffy />

<cfif not application._taffy.settings.suppressTaffyHeaders >
<cfheader name="X-TAFFY-RELOADED" value="true" />
</cfif>
</cffunction>

<cffunction name="parseRequest" access="private" output="false" returnType="struct">
Expand Down
Loading