IT 취미생활.  
Front Page
Tag | Location | Media | Guestbook | Admin   
 
Spring Kotlin Webflux URL 길이로 인한 413 에러 해결 (413 error)

How to increase HTTP Header Size, getting 413 error

 

Get API에 413에러를 받는 경우가 발생한다. 이는 URL로 요청하는 사이즈가 스프링 네티에 설정된 max-inital-line-lenght를 넘어서 발생하는 경우이다. 

 

해결 방법으로는 applicaiton.yml을 통해 네티 설정을 하는 방법이 있지만, 확실한 방법으로  WebServerFactoryCustomizer<NettyReactiveWebServerFactor>를 받아 

maxInitialLineLength()값을 조정하여 해결 가능.

import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory
import org.springframework.boot.web.embedded.netty.NettyServerCustomizer
import org.springframework.boot.web.server.WebServerFactoryCustomizer
import org.springframework.stereotype.Component
import reactor.netty.http.server.HttpRequestDecoderSpec
import reactor.netty.http.server.HttpServer


@Component
class WebConfiguration : WebServerFactoryCustomizer<NettyReactiveWebServerFactory> {
    @Value("\${server.netty.max-initial-line-length}")
    private var maxInitialLingLength: Int = 0

    override fun customize(serverFactory: NettyReactiveWebServerFactory) {
        serverFactory.addServerCustomizers(NettyServerCustomizer { httpServer: HttpServer ->
            httpServer.httpRequestDecoder { httpRequestDecoderSpec: HttpRequestDecoderSpec ->
                httpRequestDecoderSpec
                    .maxInitialLineLength(maxInitialLingLength) // request param 최대 길이 변경
            }
        })
    }
}

 

 

위에 코드 처럼  application.yml에 해당 값을 둬서 Develop staging에 따라 설정을 overlay 시켜 사용하며, config를 통해 빌드하지  수정가능하겠다. 

 

 

출처 : https://github.com/spring-cloud/spring-cloud-gateway/issues/402

 

How to increase HTTP Header Size, getting 413 error · Issue #402 · spring-cloud/spring-cloud-gateway

The layer that calls Spring Cloud Gateway API passes some SAML tokens that are more than the default header size on Netty, and we get a 413 or 'Request entity too large' error. We tried inc...

github.com

 



BLOG main image
취미생활
 Notice
 Category
분류 전체보기 (191)
매일매일갱생 (83)
서버개발 (1)
임베디드개발 (12)
Programming (80)
Personal Projects (6)
유용한 프로그램 (0)
 TAGS
warning isdbt DVB Algorithm Error Case English 서태지 Windows Mobile6.0 C C++ 음식 1seg 벨소리 변경 영어 이메일 project ISDB-T 알고리즘 debugging DirectShow Linux Wince5.0 Debug VC++ 티스토리 초대장 미라지폰 티스토리초대 군대 Brazil 퇴사 Java Dshow MP3 english email spam mail M480 출장 개발자 It DVB-T
 Calendar
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
 Recent Entries
 Recent Comments
 Recent Trackbacks
 Archive
 Link Site
zextor
괴짜 프로그래머의 일상사~@@
Gag & Peace, and more..
Kazakhstan Almaty.......
Min-A
Sadgarret
Steve Yoon's log
가슴 뛰는 삶을 살아라
오스틴 파워
GUI sin
melanie parker_Lady
제레미의 TV 2.0 이야기..
 Visitor Statistics
Total :
Today :
Yesterday :
rss