mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Make more major improvements to redbean
- POSIX regular expressions for Lua - Improved protocol parsing and encoding - Additional APIs for ZIP storage retrieval - Fix st_mode issue on NT for regular files - Generalized APIs for URL and Host handling - Worked out the kinks in resource resolution - Allow for custom error pages like /404.html
This commit is contained in:
parent
26ac6871da
commit
4effa23528
74 changed files with 3710 additions and 14246 deletions
|
@ -20,11 +20,11 @@
|
|||
#include "libc/testlib/testlib.h"
|
||||
#include "net/http/http.h"
|
||||
|
||||
TEST(ParseHttpRange, testEmptyHack) {
|
||||
TEST(ParseHttpRange, testEmptyHack_refusedBecauseItWontEncodeInContentRange) {
|
||||
long start, length;
|
||||
const char *s = "bytes=-0";
|
||||
EXPECT_TRUE(ParseHttpRange(s, strlen(s), 100, &start, &length));
|
||||
EXPECT_EQ(100, start);
|
||||
EXPECT_FALSE(ParseHttpRange(s, strlen(s), 100, &start, &length));
|
||||
EXPECT_EQ(0, start);
|
||||
EXPECT_EQ(0, length);
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,22 @@ TEST(ParseHttpRange, testEmptyRange_isntEmpty) {
|
|||
EXPECT_EQ(1, length);
|
||||
}
|
||||
|
||||
TEST(ParseHttpRange, testEmptyRangeOfOneByteFile_itWorks) {
|
||||
long start, length;
|
||||
const char *s = "bytes=0-0";
|
||||
EXPECT_TRUE(ParseHttpRange(s, strlen(s), 1, &start, &length));
|
||||
EXPECT_EQ(0, start);
|
||||
EXPECT_EQ(1, length);
|
||||
}
|
||||
|
||||
TEST(ParseHttpRange, testEmptyRangeOfEmptyFile_outOfRange) {
|
||||
long start, length;
|
||||
const char *s = "bytes=0-0";
|
||||
EXPECT_FALSE(ParseHttpRange(s, strlen(s), 0, &start, &length));
|
||||
EXPECT_EQ(0, start);
|
||||
EXPECT_EQ(0, length);
|
||||
}
|
||||
|
||||
TEST(ParseHttpRange, testInclusiveIndexing) {
|
||||
long start, length;
|
||||
const char *s = "bytes=0-10";
|
||||
|
@ -81,7 +97,7 @@ TEST(ParseHttpRange, testOutOfRange) {
|
|||
const char *s = "bytes=0-100";
|
||||
EXPECT_FALSE(ParseHttpRange(s, strlen(s), 100, &start, &length));
|
||||
EXPECT_EQ(0, start);
|
||||
EXPECT_EQ(101, length);
|
||||
EXPECT_EQ(0, length);
|
||||
}
|
||||
|
||||
TEST(ParseHttpRange, testInvalidRange) {
|
||||
|
@ -104,6 +120,14 @@ TEST(ParseHttpRange, testOverflow_duringAddition_setsErrorRange) {
|
|||
long start, length;
|
||||
const char *s = "bytes=4611686018427387904-4611686018427387915";
|
||||
EXPECT_FALSE(ParseHttpRange(s, strlen(s), 100, &start, &length));
|
||||
EXPECT_EQ(4611686018427387904, start);
|
||||
EXPECT_EQ(12, length);
|
||||
EXPECT_EQ(0, start);
|
||||
EXPECT_EQ(0, length);
|
||||
}
|
||||
|
||||
TEST(ParseHttpRange, testMultipartRange_notImplemented) {
|
||||
long start, length;
|
||||
const char *s = "bytes=0-100,200-300";
|
||||
EXPECT_FALSE(ParseHttpRange(s, strlen(s), 100, &start, &length));
|
||||
EXPECT_EQ(0, start);
|
||||
EXPECT_EQ(0, length);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue