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
5f629511
Commit
5f629511
authored
9 years ago
by
Sergey Lyubka
Committed by
rojer
9 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Runtime DAV auth disable. Implement MOVE
PUBLISHED_FROM=aec49928891972ecd6af9999fe3e1cb5ef00f24c
parent
2207e87c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
20 deletions
+31
-20
mongoose.c
mongoose.c
+27
-19
mongoose.h
mongoose.h
+4
-1
No files found.
mongoose.c
View file @
5f629511
...
...
@@ -4641,10 +4641,8 @@ void mg_send_head(struct mg_connection *c, int status_code,
static
void
send_http_error
(
struct
mg_connection
*
nc
,
int
code
,
const
char
*
reason
)
{
if
(
reason
==
NULL
)
{
reason
=
""
;
}
mg_printf
(
nc
,
"HTTP/1.1 %d %s
\r\n
Content-Length: 0
\r\n\r\n
"
,
code
,
reason
);
(
void
)
reason
;
mg_send_head
(
nc
,
code
,
0
,
NULL
);
}
#ifndef MG_DISABLE_SSI
...
...
@@ -5513,18 +5511,28 @@ static int remove_directory(const struct mg_serve_http_opts *opts,
return
1
;
}
static
void
handle_move
(
struct
mg_connection
*
n
c
,
static
void
handle_move
(
struct
mg_connection
*
c
,
const
struct
mg_serve_http_opts
*
opts
,
const
char
*
path
,
struct
http_message
*
hm
)
{
/*
* This method is not implemented now, but at least
* we have to send error 501
*/
(
void
)
nc
;
(
void
)
opts
;
(
void
)
path
;
(
void
)
hm
;
send_http_error
(
nc
,
501
,
"Not implemented"
);
const
struct
mg_str
*
dest
=
mg_get_http_header
(
hm
,
"Destination"
);
if
(
dest
==
NULL
)
{
send_http_error
(
c
,
411
,
NULL
);
}
else
{
const
char
*
p
=
(
char
*
)
memchr
(
dest
->
p
,
'/'
,
dest
->
len
);
if
(
p
!=
NULL
&&
p
[
1
]
==
'/'
&&
(
p
=
(
char
*
)
memchr
(
p
+
2
,
'/'
,
dest
->
p
+
dest
->
len
-
p
))
!=
NULL
)
{
char
buf
[
MAX_PATH_SIZE
];
snprintf
(
buf
,
sizeof
(
buf
),
"%s%.*s"
,
opts
->
dav_document_root
,
(
int
)
(
dest
->
p
+
dest
->
len
-
p
),
p
);
if
(
rename
(
path
,
buf
)
==
0
)
{
send_http_error
(
c
,
200
,
NULL
);
}
else
{
send_http_error
(
c
,
418
,
NULL
);
}
}
else
{
send_http_error
(
c
,
500
,
NULL
);
}
}
}
static
void
handle_delete
(
struct
mg_connection
*
nc
,
...
...
@@ -5545,10 +5553,10 @@ static void handle_delete(struct mg_connection *nc,
/* Return -1 on error, 1 on success. */
static
int
create_itermediate_directories
(
const
char
*
path
)
{
const
char
*
s
=
path
;
const
char
*
s
;
/* Create intermediate directories if they do not exist */
while
(
*
s
)
{
for
(
s
=
path
+
1
;
*
s
!=
'\0'
;
s
++
)
{
if
(
*
s
==
'/'
)
{
char
buf
[
MAX_PATH_SIZE
];
cs_stat_t
st
;
...
...
@@ -5558,7 +5566,6 @@ static int create_itermediate_directories(const char *path) {
return
-
1
;
}
}
s
++
;
}
return
1
;
...
...
@@ -6287,8 +6294,9 @@ void mg_send_http_file(struct mg_connection *nc, char *path,
#ifndef MG_DISABLE_DAV_AUTH
}
else
if
(
is_dav
&&
(
opts
->
dav_auth_file
==
NULL
||
!
is_authorized
(
hm
,
path
,
is_directory
,
opts
->
auth_domain
,
opts
->
dav_auth_file
,
1
)))
{
(
strcmp
(
opts
->
dav_auth_file
,
"-"
)
!=
0
&&
!
is_authorized
(
hm
,
path
,
is_directory
,
opts
->
auth_domain
,
opts
->
dav_auth_file
,
1
))))
{
mg_send_digest_auth_request
(
nc
,
opts
->
auth_domain
);
#endif
}
else
if
(
!
mg_vcmp
(
&
hm
->
method
,
"MKCOL"
))
{
...
...
This diff is collapsed.
Click to expand it.
mongoose.h
View file @
5f629511
...
...
@@ -1874,7 +1874,10 @@ struct mg_serve_http_opts {
/* DAV document root. If NULL, DAV requests are going to fail. */
const
char
*
dav_document_root
;
/* DAV passwords file. If NULL, DAV requests are going to fail. */
/*
* DAV passwords file. If NULL, DAV requests are going to fail.
* If passwords file is set to "-", then DAV auth is disabled.
*/
const
char
*
dav_auth_file
;
/* Glob pattern for the files to hide. */
...
...
This diff is collapsed.
Click to expand it.
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