How do I throttle request message size in Apigee?

Hi,

I have many proxies configured on Apigee. I want to throttle the request message size from clients to particular size(for instance 2mb) for a single proxy(other proxies should follow default rules). How do I go about it?

1 3 554
3 REPLIES 3

Got it working.

Post an answer on how you got it working.

It will be useful to others.

@Siddharth Barahalikar

We need to add the below script in preflow which will give us the message size in bytes.

var requestContent = context.getVariable('request.content');

var contentLength = requestContent.length;

context.setVariable("request.header.Content-Length", contentLength);

Then put a conditional flow to raise a fault if the request message is bigger than the allowed limit, something like below.

<PreFlow name="PreFlow">

<Request>

<Step>

<Name>JavaScript-3</Name>

</Step>

<Step>

<Name>Raise-Fault-2</Name>

<Condition>(request.header.Content-Length > "2000")</Condition>

</Step>

</Request> <Response/>

</PreFlow>