Spring WebFlux ServerWebExchange getFormData content-type

Viewed 746

I am trying to read data from request by

    class SomeFilter : WebFilter {
    override fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void> {
        return exchange.formData.map { map ->
            checkData(map)
...
}

There are 2 options to read value legally (other options will lock the tread and throw

java.lang.IllegalStateException: Only one connection receive subscriber allowed.

)

org.springframework.web.server.ServerWebExchange

    /**
     * Return the form data from the body of the request if the Content-Type is
     * {@code "application/x-www-form-urlencoded"} or an empty map otherwise.
     * <p><strong>Note:</strong> calling this method causes the request body to
     * be read and parsed in full and the resulting {@code MultiValueMap} is
     * cached so that this method is safe to call more than once.
     */
    Mono<MultiValueMap<String, String>> getFormData();

    /**
     * Return the parts of a multipart request if the Content-Type is
     * {@code "multipart/form-data"} or an empty map otherwise.
     * <p><strong>Note:</strong> calling this method causes the request body to
     * be read and parsed in full and the resulting {@code MultiValueMap} is
     * cached so that this method is safe to call more than once.
     */
    Mono<MultiValueMap<String, Part>> getMultipartData();

So then I using other content types f.e. application/json this methods giving me nothing.

Why this content types was chosen? Can I somehow use other content types without getting "Only one connection receive subscriber allowed."?

0 Answers
Related