This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
! can: make Content-Length a long value, fixes #443
API changes: * `Content-Length`.length is now a Long * `max-content-length` setting is now also a Long * `incoming-auto-chunking-threshold-size` is now also a Long This change makes only sense in combination with (auto-)chunking, because we are not able to support byte arrays (HttpEntities) bigger than Int.MaxValue.
- Loading branch information
Showing
10 changed files
with
109 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
spray-can-tests/src/test/scala/spray/can/parsing/ContentLengthHeaderParserSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package spray.can.parsing | ||
|
||
import org.specs2.mutable.Specification | ||
import java.math.BigInteger | ||
import spray.can.parsing.SpecializedHeaderValueParsers.ContentLengthParser | ||
import akka.util.ByteString | ||
import spray.http.HttpHeaders.`Content-Length` | ||
|
||
class ContentLengthHeaderParserSpec extends Specification { | ||
"specialized ContentLength parser" should { | ||
"accept zero" in { | ||
parse("0") === 0L | ||
} | ||
"accept positive value" in { | ||
parse("43234398") === 43234398L | ||
} | ||
"accept positive value > Int.MaxValue <= Long.MaxValue" in { | ||
parse("274877906944") === 274877906944L | ||
parse("9223372036854775807") === 9223372036854775807L // Long.MaxValue | ||
} | ||
"don't accept positive value > Long.MaxValue" in { | ||
parse("9223372036854775808") must throwA[ParsingException] // Long.MaxValue + 1 | ||
parse("92233720368547758070") must throwA[ParsingException] // Long.MaxValue * 10 which is 0 taken overflow into account | ||
parse("92233720368547758080") must throwA[ParsingException] // (Long.MaxValue + 1) * 10 which is 0 taken overflow into account | ||
} | ||
} | ||
|
||
def parse(bigint: String): Long = { | ||
val (`Content-Length`(length), _) = ContentLengthParser(ByteString(bigint + "\r\n").compact, 0, _ ⇒ ()) | ||
length | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters