scalaspraycontent-lengthhttp-content-lengthspray-can

Set max-content for single spray-can pipeline


I have an application that uses spray-can, and there is one module that periodically requests a very large amount of information from an http endpoint using a pipeline. This request is an anomaly when compared to the rest of the requests that we do in that its response is often several megabytes.

I currently have the following in my application.conf:

spray.can.client.parsing {
   max-content-length = 8m
}

While I know that I can increase this value to one that is acceptable for this module, I'd rather not increase the global limit max-content-length variable if only one module needs the increased limit.

Is there any way to define max-content-length for a single pipeline?


Solution

  • I don't think you will be able to configure different pipeline types. I recently answered a similar question about configuring spray-can for some pipelines, and unfortunately the problem is the same.

    The reason for this to happen is that all the configuration for the http client is only done at compilation time. In fact, we wouldn't have any problem if we could configure our own ClientConnectionSettings with our own ParserSettings and inject it to the Http object. But the Http object doesn't accept any "runtime" configuration.