Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mongoose
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ganil-acq
GANILinux
linux-service
library
mongoose
Commits
2f49e63d
Commit
2f49e63d
authored
11 years ago
by
Sergey Lyubka
Browse files
Options
Downloads
Patches
Plain Diff
Moved docstrings to API.md
parent
988b40f7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/API.md
+21
-0
21 additions, 0 deletions
docs/API.md
mongoose.h
+1
-20
1 addition, 20 deletions
mongoose.h
with
22 additions
and
20 deletions
docs/API.md
+
21
−
0
View file @
2f49e63d
...
@@ -176,6 +176,27 @@ Return: number of bytes written to the client. If return value is less then
...
@@ -176,6 +176,27 @@ Return: number of bytes written to the client. If return value is less then
`data_len`
, it is a failure, meaning that client has closed the connection.
`data_len`
, it is a failure, meaning that client has closed the connection.
int mg_printf(struct mg_connection *, const char *fmt, ...);
Send data to the client using printf() semantics.
Works exactly like mg_write(), but allows to do message formatting.
void mg_send_file(struct mg_connection *conn, const char *path);
Send contents of the entire file together with HTTP headers.
int mg_read(struct mg_connection *, void *buf, int len);
Read data from the remote end, return number of bytes read.
If remote side has closed the connection, return value is less or equal to 0.
const char *mg_get_header(const struct mg_connection *, const char *name);
Get the value of particular HTTP header. This is a helper function.
It traverses http_headers array, and if the header is present in the array,
returns its value. If it is not present, NULL is returned.
## Embedding Examples
## Embedding Examples
The common pattern is to handle
`MG_REQUEST_BEGIN`
and serve static files
The common pattern is to handle
`MG_REQUEST_BEGIN`
and serve static files
...
...
This diff is collapsed.
Click to expand it.
mongoose.h
+
1
−
20
View file @
2f49e63d
...
@@ -47,6 +47,7 @@ struct mg_request_info {
...
@@ -47,6 +47,7 @@ struct mg_request_info {
}
http_headers
[
64
];
// Maximum 64 headers
}
http_headers
[
64
];
// Maximum 64 headers
};
};
// This structure is passed to the user's event handler function.
struct
mg_event
{
struct
mg_event
{
int
type
;
// Event type, possible types are defined below
int
type
;
// Event type, possible types are defined below
#define MG_REQUEST_BEGIN 1 // event_param: NULL
#define MG_REQUEST_BEGIN 1 // event_param: NULL
...
@@ -111,30 +112,10 @@ int mg_write(struct mg_connection *, const void *buf, int len);
...
@@ -111,30 +112,10 @@ int mg_write(struct mg_connection *, const void *buf, int len);
#define PRINTF_ARGS(x, y)
#define PRINTF_ARGS(x, y)
#endif
#endif
// Send data to the client using printf() semantics.
//
// Works exactly like mg_write(), but allows to do message formatting.
int
mg_printf
(
struct
mg_connection
*
,
int
mg_printf
(
struct
mg_connection
*
,
PRINTF_FORMAT_STRING
(
const
char
*
fmt
),
...)
PRINTF_ARGS
(
2
,
3
);
PRINTF_FORMAT_STRING
(
const
char
*
fmt
),
...)
PRINTF_ARGS
(
2
,
3
);
// Send contents of the entire file together with HTTP headers.
void
mg_send_file
(
struct
mg_connection
*
conn
,
const
char
*
path
);
void
mg_send_file
(
struct
mg_connection
*
conn
,
const
char
*
path
);
// Read data from the remote end, return number of bytes read.
// Return:
// 0 connection has been closed by peer. No more data could be read.
// < 0 read error. No more data could be read from the connection.
// > 0 number of bytes read into the buffer.
int
mg_read
(
struct
mg_connection
*
,
void
*
buf
,
int
len
);
int
mg_read
(
struct
mg_connection
*
,
void
*
buf
,
int
len
);
// Get the value of particular HTTP header.
//
// This is a helper function. It traverses request_info->http_headers array,
// and if the header is present in the array, returns its value. If it is
// not present, NULL is returned.
const
char
*
mg_get_header
(
const
struct
mg_connection
*
,
const
char
*
name
);
const
char
*
mg_get_header
(
const
struct
mg_connection
*
,
const
char
*
name
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment