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
6192d1b5
Commit
6192d1b5
authored
Dec 03, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added send_http_error()
parent
daa91751
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
12 deletions
+15
-12
core.c
build/src/core.c
+15
-12
No files found.
build/src/core.c
View file @
6192d1b5
...
...
@@ -1174,6 +1174,13 @@ static int substitute_index_file(struct connection *conn, char *path,
return
found
;
}
static
void
send_http_error
(
struct
connection
*
conn
,
const
char
*
fmt
,
...)
{
va_list
ap
;
va_start
(
ap
,
fmt
);
vspool
(
&
conn
->
remote_iobuf
,
fmt
,
ap
);
va_end
(
ap
);
conn
->
flags
|=
CONN_SPOOL_DONE
;
}
static
void
open_local_endpoint
(
struct
connection
*
conn
)
{
char
path
[
MAX_PATH_SIZE
]
=
{
'\0'
};
...
...
@@ -1197,25 +1204,21 @@ static void open_local_endpoint(struct connection *conn) {
is_directory
=
S_ISDIR
(
st
.
st_mode
);
if
(
!
exists
)
{
mg_printf
(
&
conn
->
mg_conn
,
"%s"
,
"HTTP/1.1 404 Not Found
\r\n\r\n
"
);
conn
->
flags
|=
CONN_SPOOL_DONE
;
send_http_error
(
conn
,
"%s"
,
"HTTP/1.1 404 Not Found
\r\n\r\n
"
);
}
else
if
(
is_directory
&&
conn
->
mg_conn
.
uri
[
uri_len
-
1
]
!=
'/'
)
{
mg_printf
(
&
conn
->
mg_
conn
,
"HTTP/1.1 301 Moved Permanently
\r\n
"
send_http_error
(
conn
,
"HTTP/1.1 301 Moved Permanently
\r\n
"
"Location: %s/
\r\n\r\n
"
,
conn
->
mg_conn
.
uri
);
conn
->
flags
|=
CONN_SPOOL_DONE
;
}
else
if
(
is_directory
&&
!
substitute_index_file
(
conn
,
path
,
sizeof
(
path
),
&
st
))
{
mg_printf
(
&
conn
->
mg_conn
,
"%s"
,
"HTTP/1.1 403 Directory Listing Denied
\r\n\r\n
"
);
conn
->
flags
|=
CONN_SPOOL_DONE
;
send_http_error
(
conn
,
"%s"
,
"HTTP/1.1 403 Listing Denied
\r\n\r\n
"
);
}
else
if
(
match_prefix
(
"**.lua$"
,
6
,
path
)
>
0
)
{
send_http_error
(
conn
,
"%s"
,
"HTTP/1.1 200 :-)
\r\n\r\n
"
)
;
}
else
if
(
is_not_modified
(
conn
,
&
st
))
{
mg_printf
(
&
conn
->
mg_conn
,
"%s"
,
"HTTP/1.1 304 Not Modified
\r\n\r\n
"
);
conn
->
flags
|=
CONN_SPOOL_DONE
;
send_http_error
(
conn
,
"%s"
,
"HTTP/1.1 304 Not Modified
\r\n\r\n
"
);
}
else
if
((
conn
->
endpoint
.
fd
=
open
(
path
,
O_RDONLY
))
!=
-
1
)
{
open_file_endpoint
(
conn
,
path
,
&
st
);
}
else
{
mg_printf
(
&
conn
->
mg_conn
,
"%s"
,
"HTTP/1.1 404 Not Found
\r\n\r\n
"
);
conn
->
flags
|=
CONN_SPOOL_DONE
;
send_http_error
(
conn
,
"%s"
,
"HTTP/1.1 404 Not Found
\r\n\r\n
"
);
}
}
...
...
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