vibe-d / vibe.d

Official vibe.d development
MIT License
1.15k stars 284 forks source link

400 error on long URLs #2195

Open p-mitana opened 6 years ago

p-mitana commented 6 years ago

I need to support long GET queries in my application (I'm implementing a service that generates images based on the GET parameters to be embedded in Markdown file). However, above 4096 (I expect, as ~3600 character long URL worked properly) characters in URL I get 400 error:

400 - Bad Request

Bad Request

Internal error information:
object.Exception@../../.dub/packages/vibe-d-0.8.4/vibe-d/stream/vibe/stream/operations.d(379): Reached maximum number of bytes while searching for end marker.
----------------
/usr/include/dmd/phobos/std/exception.d:515 pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, scope const(char)[]) [0x12ba7ae6]
/usr/include/dmd/phobos/std/exception.d:436 pure @safe bool std.exception.enforce!().enforce!(bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0x12ba7a62]
../../.dub/packages/vibe-d-0.8.4/vibe-d/stream/vibe/stream/operations.d:379 @safe void vibe.stream.operations.readUntilSmall!(vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, vibe.internal.freelistref.FreeListRef!(vibe.http.server.LimitedHTTPInputStream, true).FreeListRef).readUntilSmall(vibe.internal.freelistref.FreeListRef!(vibe.http.server.LimitedHTTPInputStream, true).FreeListRef, ref vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, const(ubyte[]), ulong) [0x12ccfc52]
../../.dub/packages/vibe-d-0.8.4/vibe-d/stream/vibe/stream/operations.d:142 @safe void vibe.stream.operations.readUntil!(vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, vibe.internal.freelistref.FreeListRef!(vibe.http.server.LimitedHTTPInputStream, true).FreeListRef).readUntil(vibe.internal.freelistref.FreeListRef!(vibe.http.server.LimitedHTTPInputStream, true).FreeListRef, ref vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, const(ubyte[]), ulong) [0x12ccfafa]
../../.dub/packages/vibe-d-0.8.4/vibe-d/stream/vibe/stream/operations.d:56 @safe void vibe.stream.operations.readLine!(vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, vibe.internal.freelistref.FreeListRef!(vibe.http.server.LimitedHTTPInputStream, true).FreeListRef).readLine(vibe.internal.freelistref.FreeListRef!(vibe.http.server.LimitedHTTPInputStream, true).FreeListRef, ref vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, ulong, immutable(char)[]) [0x12ccfa3d]
../../.dub/packages/vibe-d-0.8.4/vibe-d/stream/vibe/stream/operations.d:41 @safe ubyte[] vibe.stream.operations.readLine!(vibe.internal.freelistref.FreeListRef!(vibe.http.server.LimitedHTTPInputStream, true).FreeListRef).readLine(vibe.internal.freelistref.FreeListRef!(vibe.http.server.LimitedHTTPInputStream, true).FreeListRef, ulong, immutable(char)[], stdx.allocator.IAllocator) [0x12ccf97b]
../../.dub/packages/vibe-d-0.8.4/vibe-d/http/vibe/http/server.d:2308 @trusted immutable(char)[] vibe.http.server.parseRequestHeader!(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.InputStream).InterfaceProxy).parseRequestHeader(vibe.http.server.HTTPServerRequest, vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.InputStream).InterfaceProxy, stdx.allocator.IAllocator, ulong).__lambda5() [0x12cbddc8]
../../.dub/packages/vibe-d-0.8.4/vibe-d/http/vibe/http/server.d:2308 @safe void vibe.http.server.parseRequestHeader!(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.InputStream).InterfaceProxy).parseRequestHeader(vibe.http.server.HTTPServerRequest, vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.InputStream).InterfaceProxy, stdx.allocator.IAllocator, ulong) [0x12cbd9a0]
../../.dub/packages/vibe-d-0.8.4/vibe-d/http/vibe/http/server.d:2142 @safe bool vibe.http.server.handleRequest(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy, vibe.core.net.TCPConnection, vibe.http.server.HTTPServerContext, ref vibe.http.server.HTTPServerSettings, ref bool, scope stdx.allocator.IAllocator) [0x12c8e0d2]
../../.dub/packages/vibe-d-0.8.4/vibe-d/http/vibe/http/server.d:241 @trusted void vibe.http.server.handleHTTPConnection(vibe.core.net.TCPConnection, vibe.http.server.HTTPServerContext).__lambda4() [0x12c8d58c]
../../.dub/packages/vibe-d-0.8.4/vibe-d/http/vibe/http/server.d:233 @safe void vibe.http.server.handleHTTPConnection(vibe.core.net.TCPConnection, vibe.http.server.HTTPServerContext) [0x12c8d29b]
../../.dub/packages/vibe-d-0.8.4/vibe-d/http/vibe/http/server.d:2006 nothrow @safe void vibe.http.server.listenHTTPPlain(vibe.http.server.HTTPServerSettings, void delegate(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse) @safe).doListen(vibe.http.server.HTTPServerContext, bool, bool).__lambda4(vibe.core.net.TCPConnection) [0x12c00829]
../../.dub/packages/vibe-core-1.4.0/vibe-core/source/vibe/core/task.d:554 void vibe.core.task.TaskFuncInfo.set!(void delegate(vibe.core.net.TCPConnection) @safe, vibe.core.net.TCPConnection).set(ref void delegate(vibe.core.net.TCPConnection) @safe, ref vibe.core.net.TCPConnection).callDelegate(ref vibe.core.task.TaskFuncInfo) [0x12ff54cc]
../../.dub/packages/vibe-core-1.4.0/vibe-core/source/vibe/core/task.d:575 void vibe.core.task.TaskFuncInfo.call() [0x12fd4d31]
../../.dub/packages/vibe-core-1.4.0/vibe-core/source/vibe/core/task.d:386 nothrow void vibe.core.task.TaskFiber.run() [0x12fd4339]
??:? void core.thread.Fiber.run() [0x13093037]
??:? fiber_entryPoint [0x13092f06]
??:? [0xffffffff]
jblachly commented 4 years ago

@the-Mitu increase maxRequestHeaderSize in httpSettings

https://github.com/vibe-d/vibe.d/blob/82222e425bff5af2b5a683b6f5bbc75a3e90a2cb/http/vibe/http/server.d#L663

dedupely commented 1 year ago

Hi, I'm getting this error as well however I have set maxRequestHeaderSize to 10MB and still getting this issue. Could this have something to do with MaxHTTPHeaderLineLength?