NozeIO / MicroExpress

A micro web server framework on top of Swift NIO
http://www.alwaysrightinstitute.com/microexpress-nio2/
126 stars 14 forks source link

Potential illegal instruction exception in ServerResponse.send() #7

Closed guillaumerose closed 5 years ago

guillaumerose commented 5 years ago

In ServerReponse send(), HTTPServerRequestPart.body can be sent after HTTPServerRequestPart.end, causing an illegal instruction exception.

If an error happens during HTTPServerRequestPart.head, then handleError() will send an end. Then send() continues and tries to send a body. A precondition is then triggered.

Code: https://github.com/NozeIO/MicroExpress/blob/master/Sources/MicroExpress/ServerResponse.swift#L4 https://github.com/apple/swift-nio/blob/master/Sources/NIOHTTP1/HTTPServerProtocolErrorHandler.swift#L65

helje5 commented 5 years ago

Hm, right.

helje5 commented 5 years ago

OK, should be fixed in 0.4.6. Thanks for reporting!