Spring WebFlux ServerWebExchange getFormData тип содержимого - PullRequest
1 голос
/ 26 мая 2020

Я пытаюсь прочитать данные из запроса по

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

Есть 2 варианта для легального чтения значения (другие варианты заблокируют протектор и выбросят

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();

Итак, я использовал другие типы контента, например application / json, эти методы мне ничего не дали.

Почему был выбран этот тип контента? Могу ли я каким-то образом использовать другие типы контента, не получая "Только одно соединение для получения подписчика разрешено."?

...