Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
9a807aa7
Commit
9a807aa7
authored
Aug 14, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added If-None-Match support
parent
5f4deeda
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
mongoose.c
mongoose.c
+13
-4
No files found.
mongoose.c
View file @
9a807aa7
...
@@ -2531,6 +2531,12 @@ static void gmt_time_string(char *buf, size_t buf_len, time_t *t) {
...
@@ -2531,6 +2531,12 @@ static void gmt_time_string(char *buf, size_t buf_len, time_t *t) {
strftime
(
buf
,
buf_len
,
"%a, %d %b %Y %H:%M:%S GMT"
,
gmtime
(
t
));
strftime
(
buf
,
buf_len
,
"%a, %d %b %Y %H:%M:%S GMT"
,
gmtime
(
t
));
}
}
static
void
construct_etag
(
char
*
buf
,
size_t
buf_len
,
const
struct
mgstat
*
stp
)
{
snprintf
(
buf
,
buf_len
,
"
\"
%lx.%"
INT64_FMT
"
\"
"
,
(
unsigned
long
)
stp
->
mtime
,
stp
->
size
);
}
static
void
handle_file_request
(
struct
mg_connection
*
conn
,
const
char
*
path
,
static
void
handle_file_request
(
struct
mg_connection
*
conn
,
const
char
*
path
,
struct
mgstat
*
stp
)
{
struct
mgstat
*
stp
)
{
char
date
[
64
],
lm
[
64
],
etag
[
64
],
range
[
64
];
char
date
[
64
],
lm
[
64
],
etag
[
64
],
range
[
64
];
...
@@ -2572,14 +2578,13 @@ static void handle_file_request(struct mg_connection *conn, const char *path,
...
@@ -2572,14 +2578,13 @@ static void handle_file_request(struct mg_connection *conn, const char *path,
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3
gmt_time_string
(
date
,
sizeof
(
date
),
&
curtime
);
gmt_time_string
(
date
,
sizeof
(
date
),
&
curtime
);
gmt_time_string
(
lm
,
sizeof
(
lm
),
&
stp
->
mtime
);
gmt_time_string
(
lm
,
sizeof
(
lm
),
&
stp
->
mtime
);
(
void
)
mg_snprintf
(
conn
,
etag
,
sizeof
(
etag
),
"%lx.%lx"
,
construct_etag
(
etag
,
sizeof
(
etag
),
stp
);
(
unsigned
long
)
stp
->
mtime
,
(
unsigned
long
)
stp
->
size
);
(
void
)
mg_printf
(
conn
,
(
void
)
mg_printf
(
conn
,
"HTTP/1.1 %d %s
\r\n
"
"HTTP/1.1 %d %s
\r\n
"
"Date: %s
\r\n
"
"Date: %s
\r\n
"
"Last-Modified: %s
\r\n
"
"Last-Modified: %s
\r\n
"
"Etag:
\"
%s
\"
\r\n
"
"Etag:
%s
\r\n
"
"Content-Type: %.*s
\r\n
"
"Content-Type: %.*s
\r\n
"
"Content-Length: %"
INT64_FMT
"
\r\n
"
"Content-Length: %"
INT64_FMT
"
\r\n
"
"Connection: %s
\r\n
"
"Connection: %s
\r\n
"
...
@@ -2737,8 +2742,12 @@ static int substitute_index_file(struct mg_connection *conn, char *path,
...
@@ -2737,8 +2742,12 @@ static int substitute_index_file(struct mg_connection *conn, char *path,
// Return True if we should reply 304 Not Modified.
// Return True if we should reply 304 Not Modified.
static
int
is_not_modified
(
const
struct
mg_connection
*
conn
,
static
int
is_not_modified
(
const
struct
mg_connection
*
conn
,
const
struct
mgstat
*
stp
)
{
const
struct
mgstat
*
stp
)
{
char
etag
[
40
];
const
char
*
ims
=
mg_get_header
(
conn
,
"If-Modified-Since"
);
const
char
*
ims
=
mg_get_header
(
conn
,
"If-Modified-Since"
);
return
ims
!=
NULL
&&
stp
->
mtime
<=
parse_date_string
(
ims
);
const
char
*
inm
=
mg_get_header
(
conn
,
"If-None-Match"
);
construct_etag
(
etag
,
sizeof
(
etag
),
stp
);
return
(
inm
!=
NULL
&&
!
mg_strcasecmp
(
etag
,
inm
))
||
(
ims
!=
NULL
&&
stp
->
mtime
<=
parse_date_string
(
ims
));
}
}
static
int
forward_body_data
(
struct
mg_connection
*
conn
,
FILE
*
fp
,
static
int
forward_body_data
(
struct
mg_connection
*
conn
,
FILE
*
fp
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment