2

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."?

Bel
  • 302
  • 4
  • 16
  • `I am trying to read data from request` what type of data, what type of request, `There are 2 options to read value legally` this depends on what type of request you are doing, if your request contains formData then, there is one, if you are doing a multipartrequest then there is one, if you are doing a application/json request then there is one. What type of request are you doing? – Toerktumlare May 26 '20 at 10:54
  • @ThomasAndolf I am trying to get application/json – Bel May 26 '20 at 15:18

0 Answers0