Removing Default Header "date"

Hi Team,

I found that by default, Apigee sent a default header and one of them is "date" header. I tried to remove that using JavaScript and AssignMessage policy in Response PostFlow but the header was still sent to the client. I need to remove this "date" header because the requirement needs another header name, let's say "timestamp", that contains the timestamp and it must be in ISO 8601 format.

JS code that I used

 

context.removeVariable('response.header.date');​

 

 
AssignMessage Policy

 

<AssignMessage continueOnError="false" enabled="true" name="AM-RemoveDefaultHeader">
    <DisplayName>AM-RemoveDefaultHeader</DisplayName>
    <Remove>
        <Headers>
            <Header name="date"/>
        </Headers>
     </Remove>
     <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
     <AssignTo createNew="false" transport="http" type="response"/>
</AssignMessage>

 

 
Proxy Flow

 

<PostFlow name="PostFlow">
    <Request>
    ...
    </Request>
    <Response>
        <Step>
            <Name>JS-RemoveDefaultHeader</Name>
        </Step>
        <Step>
            <Name>AM-RemoveDefaultHeader</Name>
        </Step>
    </Response>
</PostFlow>

 

0 2 216
2 REPLIES 2

Apigee sent a default header and one of them is "date" header. I tried to remove that using JavaScript and AssignMessage policy in Response PostFlow but the header was still sent to the client. I need to remove this "date" header because the requirement needs another header name, let's say "timestamp", that contains the timestamp and it must be in ISO 8601 format.

Ya, I think the date header is being added by a load balancer outside of the Apigee Message processor. Which means when you try to remove it within APigee, that works, but omething else in the path is adding it back in.

Is it possible that your client will accept the timestamp header even if the date header is present? You can inject the timestamp header formatted the way you want (via JS or a static message template function probably).

Ah, I see so it can't be removed.

Yes, that is possible. The main concern is it might confuse the client because it will be 2 headers related to timestamp, but we'll try to tell the clients to ignore the "date" header instead.

Thanks!