Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion on content-length mismatch #21

Open
zevv opened this issue Jan 23, 2019 · 1 comment

Comments

@zevv
Copy link

commented Jan 23, 2019

Reproduce with

import options, asyncdispatch

import httpbeast

proc onRequest(req: Request): Future[void] =
  if req.httpMethod == some(HttpPost):
    case req.path.get()
    of "/":
      req.send("Hello World")
    else:
      req.send(Http404)

run(onRequest)

Then send a faulty HTTP request with:

curl -v -XPOST http://127.0.0.1:8080/ -d/etc/services -H "Content-Length: 12"

Results in:

httpbeast.nim(421)       run
httpbeast.nim(414)       run
httpbeast.nim(287)       eventLoop
httpbeast.nim(203)       processEvents
httpbeast.nim(140)       bodyInTransit
system.nim(3877)         failedAssertImpl
system.nim(3870)         raiseAssert
system.nim(2916)         sysFatal
Error: unhandled exception: /home/idoornekamp/.nimble/pkgs/httpbeast-0.2.1/httpbeast.nim(140, 9) `not
  trueLen < bodyLen`  [AssertionError]```

IMHO asserting or throwing on faulty remote data is not right here.

@dom96

This comment has been minimized.

Copy link
Owner

commented Jan 23, 2019

Indeed :)

This is why you should put nginx in front of httpbeast, for now at least.

We need to properly fuzz httpbeast and fix this issues, with hopefully as little performance regressions as possible.

@dom96 dom96 added the bug label Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.