Skip to content

Commit

Permalink
fix: update implementation of FromAsciiString.encode
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Apr 1, 2022
1 parent d978571 commit d667f6b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zio-http/src/main/scala/zhttp/http/HttpData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ object HttpData {

private[zhttp] case class FromAsciiString(asciiString: AsciiString) extends Complete {

private def encode: ByteBuf = Unpooled.wrappedBuffer(asciiString.array())

/**
* Encodes the HttpData into a ByteBuf. Takes in ByteBufConfig to have a
* more fine grained control over the encoding.
*/
override def toByteBuf(config: ByteBufConfig): Task[ByteBuf] = Task(Unpooled.wrappedBuffer(asciiString.array()))
override def toByteBuf(config: ByteBufConfig): Task[ByteBuf] = Task(encode)

/**
* Encodes the HttpData into a Stream of ByteBufs. Takes in ByteBufConfig to
Expand All @@ -192,7 +194,7 @@ object HttpData {
* in certain cases. Takes in ByteBufConfig to have a more fine grained
* control over the encoding.
*/
override def toHttp(config: ByteBufConfig): Http[Any, Throwable, Any, ByteBuf] = ???
override def toHttp(config: ByteBufConfig): Http[Any, Throwable, Any, ByteBuf] = Http.attempt(encode)
}

private[zhttp] final case class BinaryChunk(data: Chunk[Byte]) extends Complete {
Expand Down

1 comment on commit d667f6b

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance Benchmark:

Concurrency: 256
Requests/sec: 977421.35

Please sign in to comment.