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
a021ebf4
Commit
a021ebf4
authored
Aug 20, 2011
by
Colin Leitner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added OPTIONS method
parent
025b11b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
mongoose.c
mongoose.c
+13
-1
No files found.
mongoose.c
View file @
a021ebf4
...
...
@@ -2601,7 +2601,8 @@ static void parse_http_headers(char **buf, struct mg_request_info *ri) {
static
int
is_valid_http_method
(
const
char
*
method
)
{
return
!
strcmp
(
method
,
"GET"
)
||
!
strcmp
(
method
,
"POST"
)
||
!
strcmp
(
method
,
"HEAD"
)
||
!
strcmp
(
method
,
"CONNECT"
)
||
!
strcmp
(
method
,
"PUT"
)
||
!
strcmp
(
method
,
"DELETE"
);
!
strcmp
(
method
,
"PUT"
)
||
!
strcmp
(
method
,
"DELETE"
)
||
!
strcmp
(
method
,
"OPTIONS"
);
}
// Parse HTTP request, fill in mg_request_info structure.
...
...
@@ -3236,6 +3237,15 @@ static void handle_ssi_file_request(struct mg_connection *conn,
}
}
static
void
send_options
(
struct
mg_connection
*
conn
)
{
conn
->
request_info
.
status_code
=
200
;
(
void
)
mg_printf
(
conn
,
"HTTP/1.1 200 OK
\r\n
"
"Allow: GET, POST, HEAD, CONNECT, PUT, DELETE, OPTIONS
\r\n\r\n
"
);
}
// This is the heart of the Mongoose's logic.
// This function is called when the request is read, parsed and validated,
// and Mongoose must decide what action to take: serve a file, or
...
...
@@ -3259,6 +3269,8 @@ static void handle_request(struct mg_connection *conn) {
send_authorization_request
(
conn
);
}
else
if
(
call_user
(
conn
,
MG_NEW_REQUEST
)
!=
NULL
)
{
// Do nothing, callback has served the request
}
else
if
(
!
strcmp
(
ri
->
request_method
,
"OPTIONS"
))
{
send_options
(
conn
);
}
else
if
(
strstr
(
path
,
PASSWORDS_FILE_NAME
))
{
// Do not allow to view passwords files
send_http_error
(
conn
,
403
,
"Forbidden"
,
"Access Forbidden"
);
...
...
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