Skip to content

Commit d7a1e89

Browse files
committed
add HttpConstants
1 parent 92f445e commit d7a1e89

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/BodyPartParser.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,16 +354,16 @@ private[http] object BodyPartParser {
354354
}
355355

356356
case class UndefinedEndOfLineConfiguration(boundary: String) extends EndOfLineConfiguration {
357+
import HttpConstants._
358+
357359
override def eol: String = "\r\n"
358-
private final val CR: Byte = 13
359-
private final val LF: Byte = 10
360360

361361
override def defineOnce(byteString: ByteString): EndOfLineConfiguration = {
362362
// Hypothesis: There is either CRLF or LF as EOL, no mix possible
363363
checkForBoundary(byteString) match {
364-
case CR => DefinedEndOfLineConfiguration("\r\n", boundary)
365-
case LF => DefinedEndOfLineConfiguration("\n", boundary)
366-
case _ => this
364+
case CR_BYTE => DefinedEndOfLineConfiguration("\r\n", boundary)
365+
case LF_BYTE => DefinedEndOfLineConfiguration("\n", boundary)
366+
case _ => this
367367
}
368368
}
369369

@@ -375,10 +375,10 @@ private[http] object BodyPartParser {
375375
if (index != -1) {
376376
val newIndex = index + boundary.length
377377
byteAt(byteString, newIndex) match {
378-
case CR =>
379-
if (byteAt(byteString, newIndex + 1) == LF) CR else findBoundary(index + 1)
380-
case LF => LF
381-
case _ => findBoundary(index + 1)
378+
case CR_BYTE =>
379+
if (byteAt(byteString, newIndex + 1) == LF_BYTE) CR_BYTE else findBoundary(index + 1)
380+
case LF_BYTE => LF_BYTE
381+
case _ => findBoundary(index + 1)
382382
}
383383
} else 0
384384
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.pekko.http.impl.util
19+
20+
import org.apache.pekko.annotation.InternalApi
21+
22+
/**
23+
* INTERNAL API
24+
*
25+
* This object contains HTTP related constants that are used in various places.
26+
* It is not intended to be used outside of the HTTP implementation.
27+
*/
28+
@InternalApi
29+
private[http] object HttpConstants {
30+
final val CR_BYTE: Byte = 13
31+
final val LF_BYTE: Byte = 10
32+
}

0 commit comments

Comments
 (0)