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
5fb275e1
Commit
5fb275e1
authored
Jan 09, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added URL rewrites for HTTP errors, to allow for error pages.
parent
9390c66b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
mongoose.c
mongoose.c
+16
-1
No files found.
mongoose.c
View file @
5fb275e1
...
...
@@ -540,9 +540,24 @@ static const char *status_code_to_str(int status_code) {
static
void
send_http_error
(
struct
connection
*
conn
,
int
code
,
const
char
*
fmt
,
...)
{
const
char
*
message
=
status_code_to_str
(
code
);
const
char
*
rewrites
=
conn
->
server
->
config_options
[
URL_REWRITES
];
char
headers
[
200
],
body
[
200
];
struct
vec
a
,
b
;
va_list
ap
;
int
body_len
,
headers_len
;
int
body_len
,
headers_len
,
match_code
;
// Handle error code rewrites
while
((
rewrites
=
next_option
(
rewrites
,
&
a
,
&
b
))
!=
NULL
)
{
if
((
match_code
=
atoi
(
a
.
ptr
))
>
0
&&
match_code
==
code
)
{
conn
->
mg_conn
.
status_code
=
302
;
mg_printf
(
&
conn
->
mg_conn
,
"HTTP/1.1 %d Moved
\r\n
"
"Location: %.*s?code=%d&orig_uri=%s
\r\n\r\n
"
,
conn
->
mg_conn
.
status_code
,
b
.
len
,
b
.
ptr
,
code
,
conn
->
mg_conn
.
uri
);
close_local_endpoint
(
conn
);
return
;
}
}
conn
->
mg_conn
.
status_code
=
code
;
body_len
=
mg_snprintf
(
body
,
sizeof
(
body
),
"%d %s
\n
"
,
code
,
message
);
...
...
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