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
531fec34
Commit
531fec34
authored
Oct 10, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added missing files
parent
4c10d1f3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
0 deletions
+87
-0
form_submit.c
examples/form_submit/form_submit.c
+62
-0
Makefile
examples/proxy_server/Makefile
+13
-0
Makefile
examples/web_server/Makefile
+12
-0
No files found.
examples/form_submit/form_submit.c
0 → 100644
View file @
531fec34
#include <stdio.h>
#include <string.h>
#include "mongoose.h"
static
const
char
*
html_form
=
"<html><body>POST example."
"<form method=
\"
POST
\"
action=
\"
/handle_post_request
\"
>"
"Input 1: <input type=
\"
text
\"
name=
\"
input_1
\"
/> <br/>"
"Input 2: <input type=
\"
text
\"
name=
\"
input_2
\"
/> <br/>"
"<input type=
\"
submit
\"
/>"
"</form></body></html>"
;
static
void
send_reply
(
struct
mg_connection
*
conn
)
{
char
var1
[
500
],
var2
[
500
];
if
(
strcmp
(
conn
->
uri
,
"/handle_post_request"
)
==
0
)
{
// User has submitted a form, show submitted data and a variable value
// Parse form data. var1 and var2 are guaranteed to be NUL-terminated
mg_get_var
(
conn
,
"input_1"
,
var1
,
sizeof
(
var1
));
mg_get_var
(
conn
,
"input_2"
,
var2
,
sizeof
(
var2
));
// Send reply to the client, showing submitted form values.
// POST data is in conn->content, data length is in conn->content_len
mg_send_header
(
conn
,
"Content-Type"
,
"text/plain"
);
mg_printf_data
(
conn
,
"Submitted data: [%.*s]
\n
"
"Submitted data length: %d bytes
\n
"
"input_1: [%s]
\n
"
"input_2: [%s]
\n
"
,
conn
->
content_len
,
conn
->
content
,
conn
->
content_len
,
var1
,
var2
);
}
else
{
// Show HTML form.
mg_send_data
(
conn
,
html_form
,
strlen
(
html_form
));
}
}
static
int
ev_handler
(
struct
mg_connection
*
conn
,
enum
mg_event
ev
)
{
if
(
ev
==
MG_REQUEST
)
{
send_reply
(
conn
);
return
MG_TRUE
;
}
else
if
(
ev
==
MG_AUTH
)
{
return
MG_TRUE
;
}
else
{
return
MG_FALSE
;
}
}
int
main
(
void
)
{
struct
mg_server
*
server
=
mg_create_server
(
NULL
,
ev_handler
);
mg_set_option
(
server
,
"listening_port"
,
"8080"
);
printf
(
"Starting on port %s
\n
"
,
mg_get_option
(
server
,
"listening_port"
));
for
(;;)
{
mg_poll_server
(
server
,
1000
);
}
mg_destroy_server
(
&
server
);
return
0
;
}
examples/proxy_server/Makefile
0 → 100644
View file @
531fec34
# Copyright (c) 2014 Cesanta Software
# All rights reserved
PROG
=
proxy_server
FLAGS
=
-I
../..
-I
../../../net_skeleton
-DNS_ENABLE_SSL
CFLAGS
=
-W
-Wall
-g
-O0
-lssl
$(FLAGS)
$(CFLAGS_EXTRA)
SOURCES
=
$(PROG)
.c ../../mongoose.c
unix
:
$(SOURCES)
$(CC)
-o
$(PROG)
$(SOURCES)
$(CFLAGS)
clean
:
rm
-rf
$(PROG)
*
.exe
*
.dSYM
*
.obj
*
.exp .
*
o
*
.lib
examples/web_server/Makefile
0 → 100644
View file @
531fec34
# Copyright (c) 2014 Cesanta Software
# All rights reserved
PROG
=
web_server
CFLAGS
=
-W
-Wall
-I
../..
-g
-O0
$(CFLAGS_EXTRA)
SOURCES
=
$(PROG)
.c ../../mongoose.c
$(PROG)
:
$(SOURCES)
$(CC)
-o
$(PROG)
$(SOURCES)
$(CFLAGS)
clean
:
rm
-rf
$(PROG)
*
.exe
*
.dSYM
*
.obj
*
.exp .
*
o
*
.lib
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