He-Pin commented on code in PR #799:
URL: https://github.com/apache/pekko-http/pull/799#discussion_r2380311421


##########
http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/BodyPartParser.scala:
##########
@@ -359,11 +359,30 @@ private[http] object BodyPartParser {
 
     override def defineOnce(byteString: ByteString): EndOfLineConfiguration = {
       // Hypothesis: There is either CRLF or LF as EOL, no mix possible
-      val crLfNeedle = ByteString(s"$boundary\r\n")
-      val lfNeedle = ByteString(s"$boundary\n")
-      if (byteString.containsSlice(crLfNeedle)) 
DefinedEndOfLineConfiguration("\r\n", boundary)
-      else if (byteString.containsSlice(lfNeedle)) 
DefinedEndOfLineConfiguration("\n", boundary)
-      else this
+      checkForBoundary(byteString) match {
+        case CR => DefinedEndOfLineConfiguration("\r\n", boundary)
+        case LF => DefinedEndOfLineConfiguration("\n", boundary)
+        case _  => this
+      }
+    }
+
+    private val CR = '\r'.toByte
+    private val LF = '\n'.toByte

Review Comment:
   Nice, There are many `LR`, `LF` thing, can we put them in a single file 
Netty does.
   io.netty.handler.codec.http.HttpConstants
   
   And use `final val LF = 10` make it a compiler constant.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to