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
Admin message
Gitlab has been updated. More info
here
.
Show more breadcrumbs
Ganil-acq
GANILinux
linux-service
library
mongoose
Commits
6192d1b5
Commit
6192d1b5
authored
11 years ago
by
Sergey Lyubka
Browse files
Options
Downloads
Patches
Plain Diff
Added send_http_error()
parent
daa91751
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
build/src/core.c
+15
-12
15 additions, 12 deletions
build/src/core.c
with
15 additions
and
12 deletions
build/src/core.c
+
15
−
12
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
"
"Location: %s/
\r\n\r\n
"
,
conn
->
mg_conn
.
uri
);
conn
->
flags
|=
CONN_SPOOL_DONE
;
send_http_error
(
conn
,
"HTTP/1.1 301 Moved Permanently
\r\n
"
"Location: %s/
\r\n\r\n
"
,
conn
->
mg_conn
.
uri
);
}
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
"
);
}
}
...
...
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