Last active
January 21, 2021 22:17
-
-
Save JamoCA/575182d2b2378ad57334e080d9a31209 to your computer and use it in GitHub Desktop.
ColdFusion / CFML UDF to determine if request/content has been flushed using CFFlush or by exceeding max buffer.
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
<cfscript> | |
/* 20200121 ColdFusion / CFML UDF to determine if request/content has been flushed using CFFlush or by exceeding max buffer. */ | |
boolean function isFlushed(){ | |
var response = false; | |
var headers = {}; | |
if (StructKeyExists(request, "isFlushedAlready") AND isValid("boolean", request.isFlushedAlready) and request.isFlushedAlready){ | |
return true; | |
} | |
headers = GetHttpRequestData(false).headers; | |
if (StructKeyExists(headers, "Expect") or not len(CGI.HTTP_Connection)){ | |
response = true; | |
} else if (StructKeyExists(Server, "lucee")){ | |
response = getPageContext().getHttpServletResponse().isCommitted() or getPageContext().getHttpServletResponse().isTreatAsCommitted(); | |
} else { | |
response = getPageContext().getResponse().isCommitted() or getPageContext().getFusionContext().getResponse().isOutputAutoFlushed(); | |
} | |
request.isFlushedAlready = response; | |
return response; | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment