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
5bbb6fbb
Commit
5bbb6fbb
authored
Jun 19, 2011
by
valenok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added mg_send_file()
parent
23a3cc64
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
mongoose.c
mongoose.c
+10
-0
mongoose.h
mongoose.h
+5
-0
No files found.
mongoose.c
View file @
5bbb6fbb
...
...
@@ -2567,6 +2567,16 @@ static void handle_file_request(struct mg_connection *conn, const char *path,
(
void
)
fclose
(
fp
);
}
void
mg_send_file
(
struct
mg_connection
*
conn
,
const
char
*
path
)
{
struct
mgstat
st
;
if
(
mg_stat
(
path
,
&
st
)
==
0
)
{
handle_file_request
(
conn
,
path
,
&
st
);
}
else
{
send_http_error
(
conn
,
404
,
"Not Found"
,
"%s"
,
"File not found"
);
}
}
// Parse HTTP headers from the given buffer, advance buffer to the point
// where parsing stopped.
static
void
parse_http_headers
(
char
**
buf
,
struct
mg_request_info
*
ri
)
{
...
...
mongoose.h
View file @
5bbb6fbb
...
...
@@ -158,6 +158,11 @@ int mg_write(struct mg_connection *, const void *buf, size_t len);
int
mg_printf
(
struct
mg_connection
*
,
const
char
*
fmt
,
...);
// Send contents of the entire file together with HTTP headers.
// Return 1 on success, 0 on error (e.g. file does not exist).
void
mg_send_file
(
struct
mg_connection
*
conn
,
const
char
*
path
);
// Read data from the remote end, return number of bytes read.
int
mg_read
(
struct
mg_connection
*
,
void
*
buf
,
size_t
len
);
...
...
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