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
c9e666ba
Commit
c9e666ba
authored
Sep 07, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://github.com/valenok/mongoose
parents
18e64397
784a1580
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
+24
-5
mongoose.c
mongoose.c
+24
-5
No files found.
mongoose.c
View file @
c9e666ba
...
...
@@ -1675,6 +1675,24 @@ int mg_printf(struct mg_connection *conn, const char *fmt, ...) {
return
mg_vprintf
(
conn
,
fmt
,
ap
);
}
int
mg_chunked_printf
(
struct
mg_connection
*
conn
,
const
char
*
fmt
,
...)
{
char
mem
[
MG_BUF_LEN
],
*
buf
=
mem
;
int
len
;
va_list
ap
;
va_start
(
ap
,
fmt
);
if
((
len
=
alloc_vprintf
(
&
buf
,
sizeof
(
mem
),
fmt
,
ap
))
>
0
)
{
len
=
mg_printf
(
conn
,
"%X
\r\n
%s
\r\n
"
,
len
,
buf
);
}
if
(
buf
!=
mem
&&
buf
!=
NULL
)
{
free
(
buf
);
}
return
len
;
}
int
mg_url_decode
(
const
char
*
src
,
int
src_len
,
char
*
dst
,
int
dst_len
,
int
is_form_url_encoded
)
{
int
i
,
j
,
a
,
b
;
...
...
@@ -2642,7 +2660,7 @@ static void print_dir_entry(struct de *de) {
strftime
(
mod
,
sizeof
(
mod
),
"%d-%b-%Y %H:%M"
,
localtime
(
&
de
->
file
.
modification_time
));
mg_url_encode
(
de
->
file_name
,
href
,
sizeof
(
href
));
de
->
conn
->
num_bytes_sent
+=
mg_printf
(
de
->
conn
,
de
->
conn
->
num_bytes_sent
+=
mg_
chunked_
printf
(
de
->
conn
,
"<tr><td><a href=
\"
%s%s%s
\"
>%s%s</a></td>"
"<td> %s</td><td> %s</td></tr>
\n
"
,
de
->
conn
->
request_info
.
uri
,
href
,
de
->
file
.
is_directory
?
"/"
:
""
,
...
...
@@ -2819,10 +2837,10 @@ static void handle_directory_request(struct mg_connection *conn,
conn
->
must_close
=
1
;
mg_printf
(
conn
,
"%s"
,
"HTTP/1.1 200 OK
\r\n
"
"
Connection: close
\r\n
"
"
Transfer-Encoding: Chunked
\r\n
"
"Content-Type: text/html; charset=utf-8
\r\n\r\n
"
);
conn
->
num_bytes_sent
+=
mg_printf
(
conn
,
conn
->
num_bytes_sent
+=
mg_
chunked_
printf
(
conn
,
"<html><head><title>Index of %s</title>"
"<style>th {text-align: left;}</style></head>"
"<body><h1>Index of %s</h1><pre><table cellpadding=
\"
0
\"
>"
...
...
@@ -2834,7 +2852,7 @@ static void handle_directory_request(struct mg_connection *conn,
sort_direction
,
sort_direction
,
sort_direction
);
// Print first entry - link to a parent directory
conn
->
num_bytes_sent
+=
mg_printf
(
conn
,
conn
->
num_bytes_sent
+=
mg_
chunked_
printf
(
conn
,
"<tr><td><a href=
\"
%s%s
\"
>%s</a></td>"
"<td> %s</td><td> %s</td></tr>
\n
"
,
conn
->
request_info
.
uri
,
".."
,
"Parent directory"
,
"-"
,
"-"
);
...
...
@@ -2848,7 +2866,8 @@ static void handle_directory_request(struct mg_connection *conn,
}
free
(
data
.
entries
);
conn
->
num_bytes_sent
+=
mg_printf
(
conn
,
"%s"
,
"</table></body></html>"
);
conn
->
num_bytes_sent
+=
mg_chunked_printf
(
conn
,
"%s"
,
"</table></body></html>"
);
conn
->
num_bytes_sent
+=
mg_write
(
conn
,
"0
\r\n\r\n
"
,
5
);
conn
->
status_code
=
200
;
}
...
...
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