api payload size based on Content-Type

Hi

I am using OPDK 4.52 (on premise version of apigee edge)

I need to set maximum limit payload of an API to 1 MB if the "Content-Type" is "application/json" and 10 MB (Default limit) for all other cases.

What is  the best approach?

Any suggestion is welcome.

Regards

Sujith Jacob 

 

0 1 217
1 REPLY 1

I can suggest something like this: 

 

  <Step>
    <Name>RF-Content-Length-Exceeds-Limit</Name>
    <Condition>(request.header.content-length > 1048576 and request.header.content-type = "application/json") OR 
        (request.header.content-length > 10485760)</Condition>
  </Step> 

 

But that won't be sufficient, as for large payloads, clients use chunked transfer encoding, which means there is no content-length header. So you would need to also restrict your API from accepting that, as well.