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
8a0bc2d6
Commit
8a0bc2d6
authored
Oct 31, 2015
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mongoose binary - GUI version fix
PUBLISHED_FROM=94c2b4c5a40c3519df6caa7561c3935bdf505575
parent
e34747d1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
mongoose.c
mongoose.c
+52
-0
No files found.
mongoose.c
View file @
8a0bc2d6
...
@@ -5914,6 +5914,56 @@ static void handle_cgi(struct mg_connection *nc, const char *prog,
...
@@ -5914,6 +5914,56 @@ static void handle_cgi(struct mg_connection *nc, const char *prog,
}
}
#endif
#endif
static
int
get_month_index
(
const
char
*
s
)
{
static
const
char
*
month_names
[]
=
{
"Jan"
,
"Feb"
,
"Mar"
,
"Apr"
,
"May"
,
"Jun"
,
"Jul"
,
"Aug"
,
"Sep"
,
"Oct"
,
"Nov"
,
"Dec"
};
size_t
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
month_names
);
i
++
)
if
(
!
strcmp
(
s
,
month_names
[
i
]))
return
(
int
)
i
;
return
-
1
;
}
static
int
num_leap_years
(
int
year
)
{
return
year
/
4
-
year
/
100
+
year
/
400
;
}
/* Parse UTC date-time string, and return the corresponding time_t value. */
static
time_t
parse_date_string
(
const
char
*
datetime
)
{
static
const
unsigned
short
days_before_month
[]
=
{
0
,
31
,
59
,
90
,
120
,
151
,
181
,
212
,
243
,
273
,
304
,
334
};
char
month_str
[
32
];
int
second
,
minute
,
hour
,
day
,
month
,
year
,
leap_days
,
days
;
time_t
result
=
(
time_t
)
0
;
if
(((
sscanf
(
datetime
,
"%d/%3s/%d %d:%d:%d"
,
&
day
,
month_str
,
&
year
,
&
hour
,
&
minute
,
&
second
)
==
6
)
||
(
sscanf
(
datetime
,
"%d %3s %d %d:%d:%d"
,
&
day
,
month_str
,
&
year
,
&
hour
,
&
minute
,
&
second
)
==
6
)
||
(
sscanf
(
datetime
,
"%*3s, %d %3s %d %d:%d:%d"
,
&
day
,
month_str
,
&
year
,
&
hour
,
&
minute
,
&
second
)
==
6
)
||
(
sscanf
(
datetime
,
"%d-%3s-%d %d:%d:%d"
,
&
day
,
month_str
,
&
year
,
&
hour
,
&
minute
,
&
second
)
==
6
))
&&
year
>
1970
&&
(
month
=
get_month_index
(
month_str
))
!=
-
1
)
{
leap_days
=
num_leap_years
(
year
)
-
num_leap_years
(
1970
);
year
-=
1970
;
days
=
year
*
365
+
days_before_month
[
month
]
+
(
day
-
1
)
+
leap_days
;
result
=
days
*
24
*
3600
+
hour
*
3600
+
minute
*
60
+
second
;
}
return
result
;
}
static
int
mg_is_not_modified
(
struct
http_message
*
hm
,
cs_stat_t
*
st
)
{
char
etag
[
64
];
struct
mg_str
*
ims
=
mg_get_http_header
(
hm
,
"If-Modified-Since"
);
struct
mg_str
*
inm
=
mg_get_http_header
(
hm
,
"If-None-Match"
);
construct_etag
(
etag
,
sizeof
(
etag
),
st
);
return
(
inm
!=
NULL
&&
!
mg_vcasecmp
(
inm
,
etag
))
||
(
ims
!=
NULL
&&
st
->
st_mtime
<=
parse_date_string
(
ims
->
p
));
}
static
void
mg_send_digest_auth_request
(
struct
mg_connection
*
c
,
static
void
mg_send_digest_auth_request
(
struct
mg_connection
*
c
,
const
char
*
domain
)
{
const
char
*
domain
)
{
mg_printf
(
c
,
mg_printf
(
c
,
...
@@ -5986,6 +6036,8 @@ void mg_send_http_file(struct mg_connection *nc, char *path,
...
@@ -5986,6 +6036,8 @@ void mg_send_http_file(struct mg_connection *nc, char *path,
#else
#else
send_http_error
(
nc
,
501
,
NULL
);
send_http_error
(
nc
,
501
,
NULL
);
#endif
/* MG_DISABLE_CGI */
#endif
/* MG_DISABLE_CGI */
}
else
if
(
mg_is_not_modified
(
hm
,
&
st
))
{
send_http_error
(
nc
,
304
,
"Not Modified"
);
}
else
{
}
else
{
mg_send_http_file2
(
nc
,
path
,
&
st
,
hm
,
opts
);
mg_send_http_file2
(
nc
,
path
,
&
st
,
hm
,
opts
);
}
}
...
...
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