adding headers to the request

95 views
Skip to first unread message

Nolan Dubeau

unread,
May 18, 2011, 2:46:52 PM5/18/11
to ColdBox Platform
Hi guys,

First off, it was great to meet and converse with so many of you at CFObjective! I'm already looking forward to next year!

I'm debating whether or not this is an app issue or an IIS issue....

In my API I am returning a 204 status header on some of my endpoints. 204 does not send any content back so I use event.noRender() after my endpoint executes. The problem that is occurring however is the content-length header is returning a value (ie 2629) when it should really return 0. I tried to force a content-length header with value 0 at the end of my request but it doesn't seem to overwrite the value. I'm struggling to figure out how to correct this, and can't determine why/how the content-length header is populated with that value. Hoping someone on the list might have an approach.

Cheers, and thanks.

Nolan

Aaron Greenlee

unread,
May 18, 2011, 3:03:47 PM5/18/11
to col...@googlegroups.com
My guess is you are seeing the amount of whitepace generated by ColdFusion. In the event you need "zero" content, perhaps you could try calling clearBuffer() as the last item in the request? I think you have to do this before onRequestEnd, but, I'm not sure.

Aaron Greenlee

Nolan Dubeau

unread,
May 18, 2011, 3:17:46 PM5/18/11
to col...@googlegroups.com
Hi Aaron,

Makes sense. I'll give that a go and let you know if that does the trick. Thanks.

Nolan


On 2011-05-18, at 3:03 PM, Aaron Greenlee wrote:

> My guess is you are seeing the amount of whitepace generated by ColdFusion. In the event you need "zero" content, perhaps you could try calling clearBuffer() as the last item in the request? I think you have to do this before onRequestEnd, but, I'm not sure.
>
> Aaron Greenlee
>

> --
> You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
> To post to this group, send email to col...@googlegroups.com
> To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
> For more options, visit this group at http://groups-beta.google.com/group/coldbox
> For News, visit http://blog.coldbox.org
> For Documentation, visit http://wiki.coldbox.org

Nolan Dubeau

unread,
May 18, 2011, 3:30:03 PM5/18/11
to col...@googlegroups.com
Hi Aaron,

Is clearBuffer() part of the CB framework or is this native to CF? i.e getPageContext().getCFOutput()

Thanks.

Nolan


On 2011-05-18, at 3:03 PM, Aaron Greenlee wrote:

> My guess is you are seeing the amount of whitepace generated by ColdFusion. In the event you need "zero" content, perhaps you could try calling clearBuffer() as the last item in the request? I think you have to do this before onRequestEnd, but, I'm not sure.
>
> Aaron Greenlee
>

Aaron Greenlee

unread,
May 18, 2011, 3:38:00 PM5/18/11
to col...@googlegroups.com
Sorry...

There are a two ways:

getPageContext().getOut().clearBuffer();

<cfcontent reset="true">

Nolan Dubeau

unread,
May 18, 2011, 3:57:49 PM5/18/11
to col...@googlegroups.com
Hi Aaron,

It looks like this will work with getPageContext()..... however I only want this this to execute on responses with 204. I'm setting the 204 header further up the request chain so i'm wondering how I would programatically call the clearBuffer() only if the 204 header had been set. Would this be as simple as adding a var to the RC or PRC and checking for it's existence in the onRequestEnd()? If exists, clearBuffer()? Or would you suggest another approach to evaulate the 204 header?

Thanks very much.

Nolan

Aaron Greenlee

unread,
May 18, 2011, 5:20:28 PM5/18/11
to col...@googlegroups.com
First, I would try checking your for a value in the RC using an interceptor's postRender() event interception. If you have a response object you can check the status code. Otherwise, just check for a boolean or something in the PRC.

If you still have whitespace, I would break the framework and assign a request.foo variable and check for it in ColdFusion's native Application.cfc framework. The ColdBox source code is really clean with respect to writing the rendered content to the output stream without having any indents or other code that can cause whitespace--so, you may not need to go outside the framework.

Please share your results!

Thanks,

Aaron Greenlee

Luis Majano

unread,
May 18, 2011, 6:25:40 PM5/18/11
to col...@googlegroups.com
In the core: coldbox.system.remote.RemotingUtil.cfc  already has this functionality available for all engines.
Reply all
Reply to author
Forward
0 new messages