title: Upload payload body to Spring Cloud Gateway before making proxy or downstream calls?
body: <p><strong>Original question (Please view edit)</strong>:</p>
  <p>In <code>nginx</code>, there is module directive called <code>proxy_read_timeout</code>: <a href="http://nginx.org/en/docs/http/ngx_http_proxy_module.html" rel="nofollow noreferrer">http://nginx.org/en/docs/http/ngx_http_proxy_module.html</a> - By default, it is <code>60s</code>, and as I understand it, this is only for calls between <code>nginx</code> and the <code>proxied service</code> like so:</p>
  <p>Client (Uploads a big file) -&gt; nginx Gateway -&gt; (Waits 60 seconds) -&gt; Downstream Service</p>
  <p>In Spring Cloud Gateway, I'm familiar you can set this:</p>
  <pre><code>spring:
    cloud:
      gateway:
        httpclient:
          response-timeout: 60s
  </code></pre>
  <p>or per route using <code>metadata</code> like this:</p>
  <pre><code>.metadata(RESPONSE_TIMEOUT_ATTR, 60)
  </code></pre>
  <p>However, this seems to set the response timeout for the entire call chain, like so:</p>
  <p>Client (Uploads a big file) -&gt; (Waits 60 seconds) Spring Cloud Gateway -&gt; Downstream Service</p>
  <p>Is there a way to set a response timeout only between SCG and the proxied service but not the whole request? Or perhaps dynamically or programatically set the response timeout on between downstream calls?</p>
  <p>I would like to limit the response time of the proxied call, but if a client is uploading a big file, it might take longer depending on their upload speed.</p>
  <hr />
  <p><strong>Edit</strong>: After some more research, <code>proxy_read_timeout</code> is behaving the same as SCG's <code>response-timeout</code> - The issue has been narrowed down to this config (we use openresty/lua-nginx-module)</p>
  <pre><code>lua_need_request_body on;
  proxy_read_timeout 10s;
  </code></pre>
  <p>With the above, I observed a 30s transfer start, and then it reached the backend service</p>
  <p><a href="https://i.stack.imgur.com/aTKOz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aTKOz.png" alt="enter image description here" /></a></p>
  <p>With this commented out:</p>
  <pre><code># lua_need_request_body on;
  proxy_read_timeout 10s;
  </code></pre>
  <p>I observed a <code>upstream timed out</code> in nginx, and transfer start getting cut short (file didn't finish uploading)</p>
  <p><a href="https://i.stack.imgur.com/z8FzN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z8FzN.png" alt="enter image description here" /></a></p>
  <p>Their doc <a href="https://github.com/openresty/lua-nginx-module#lua_need_request_body" rel="nofollow noreferrer">https://github.com/openresty/lua-nginx-module#lua_need_request_body</a> indicates:</p>
  <pre><code>Determines whether to force the request body data to be read before running rewrite/access/content_by_lua* or not.
  </code></pre>
  <p>So they must be doing payload body processing before anything else takes over.</p>
  <p>So the new question is, can Spring Cloud Gateway process uploading the file before any response-timeout settings kick in?</p>