Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,22 @@ class BlazeClientSuite extends BlazeClientBase {

test("Blaze HTTP/1 client should raise a ResponseException when it receives an unexpected EOF") {
Network[IO]
.serverResource(address = None, port = None, options = Nil)
.map { case (addr, sockets) =>
.bind()
.map { socket =>
val addr = socket.address.asIpUnsafe
val uri =
Uri.fromString(s"http://[${addr.host.toString()}]:${addr.port.toString()}/eof").yolo
val req = Request[IO](uri = uri)
(req, sockets)
(req, socket)
}
.use { case (req, sockets) =>
.use { case (req, socket) =>
Stream
.eval(builder(1).resource.use { client =>
interceptMessageIO[SocketException](
s"HTTP connection closed: ${RequestKey.fromRequest(req)}"
)(client.expect[String](req))
})
.concurrently(sockets.evalMap(s => s.endOfInput *> s.endOfOutput))
.concurrently(socket.accept.evalMap(s => s.endOfInput *> s.endOfOutput))
.compile
.drain
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package org.http4s.blaze.server

import org.http4s.blaze.core.websocket.WebSocketMessageTooLargeException
import org.http4s.blaze.pipeline.MidStage
import org.http4s.blaze.server.WSFrameAggregator.Accumulator
import org.http4s.blaze.util.Execution._
import org.http4s.blaze.core.websocket.WebSocketMessageTooLargeException
import org.http4s.internal.bug
import org.http4s.websocket.WebSocketFrame
import org.http4s.websocket.WebSocketFrame._
Expand All @@ -40,7 +40,7 @@ private class WSFrameAggregator(maxMessageSize: Int)
@deprecated("Preserved for binary compatibility", "0.23.18")
private[WSFrameAggregator] def this() =
this(WSFrameAggregator.DefaultMaxMessageSize)

private[this] val accumulator = new Accumulator

// Each buffered fragment also costs per-object heap (queue node, frame,
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Benchmarks extends BlazeTestSuite {
val headers = "From: someuser@jmarshall.com \r\n" +
"HOST: www.foo.com\r\n" +
"User-Agent: HTTPTool/1.0 \r\n" +
"Some-Header\r\n" +
"Some-Header:\r\n" +
"\r\n"

val body = "hello world"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ClientParserSuite extends BlazeTestSuite {
.map { case (a, b) =>
a + (if (b.length > 0)
": " + b
else "")
else ":")
}
.mkString("\r\n") + "\r\n\r\n"

Expand Down Expand Up @@ -253,22 +253,11 @@ class ClientParserSuite extends BlazeTestSuite {
}

test(
"A client parser should parse a body with a Content-Length and `Transfer-Encoding: identity` header"
"A client parser should not parse a body with a Content-Length and `Transfer-Encoding: identity` header"
) {
val p = new TestParser
val full = resp + content_length + "Transfer-Encoding: identity\r\n" + l_headersstr + body
val bts = wrap(full.getBytes(ISO_8859_1))

assert(p.parseResponse(bts))
assert(p.parseheaders(bts))

assertEquals(p.contentComplete(), false)

val out = p.parsebody(bts)
assertEquals(out.remaining(), body.length)

assert(p.contentComplete())

assertEquals(ISO_8859_1.decode(out).toString, body)
intercept[BadMessage](p.parseheaders(bts))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class ServerParserSuite extends BlazeTestSuite {
hs.foldLeft(new StringBuilder) { (sb, h) =>
sb.append(h._1)
if (h._2.length > 0) sb.append(": " + h._2)
else sb.append(':')
sb.append("\r\n")
}.append("\r\n")
.result()
Expand Down Expand Up @@ -224,16 +225,16 @@ class ServerParserSuite extends BlazeTestSuite {
}
}

test("An Http1ServerParser should accept headers without values") {
test("An Http1ServerParser should accept headers without values as long as it has a colon") {
val hsStr =
"If-Modified-Since\r\nIf-Modified-Since:\r\nIf-Modified-Since: \r\nIf-Modified-Since:\t\r\n\r\n"
"If-Modified-Since:\r\nIf-Modified-Since: \r\nIf-Modified-Since:\t\r\n\r\n"
val p = new Parser()
assert(p.parseheaders(hsStr))
assertEquals(
p.getContentType,
EndOfContent.END
) // since the headers didn't indicate any content
assertEquals(p.h.result(), List.fill(4)(("If-Modified-Since", "")))
assertEquals(p.h.result(), List.fill(3)(("If-Modified-Since", "")))
}

test("An Http1ServerParser should need input on partial headers") {
Expand Down Expand Up @@ -304,7 +305,7 @@ class ServerParserSuite extends BlazeTestSuite {

test("An Http1ServerParser should parse a chunked request with trailers") {
val p = new Parser()
val req = mockChunked.substring(0, mockChunked.length - 2) + "Foo\r\n\r\n"
val req = mockChunked.substring(0, mockChunked.length - 2) + "Foo:\r\n\r\n"
val b = strToBuffer(req)

// println(mockChunked)
Expand Down Expand Up @@ -354,7 +355,7 @@ class ServerParserSuite extends BlazeTestSuite {

test("An Http1ServerParser should give parse a chunked request in fragments with a trailer") {
val p = new Parser()
val req = mockChunked.substring(0, mockChunked.length - 2) + "Foo\r\n\r\n"
val req = mockChunked.substring(0, mockChunked.length - 2) + "Foo:\r\n\r\n"
val b = strToBuffer(req)
val blim = b.limit()

Expand Down
Loading