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
d333c3c0
Commit
d333c3c0
authored
9 years ago
by
Alexander Alashkin
Committed by
rojer
9 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement fake DAV LOCK
PUBLISHED_FROM=0ea0d8623ab3f59de8996f6b18712d1b3fb120f8
parent
81d977c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
3 deletions
+55
-3
Makefile
examples/simplest_web_server/Makefile
+2
-1
mongoose.c
mongoose.c
+53
-2
No files found.
examples/simplest_web_server/Makefile
View file @
d333c3c0
PROG
=
simplest_web_server
SOURCES
=
$(PROG)
.c ../../mongoose.c
CFLAGS
=
-W
-Wall
-I
../..
$(CFLAGS_EXTRA)
-DMG_DISABLE_DAV_AUTH
CFLAGS
=
-W
-Wall
-I
../..
$(CFLAGS_EXTRA)
-DMG_DISABLE_DAV_AUTH
\
-DMG_ENABLE_FAKE_DAVLOCK
all
:
$(PROG)
...
...
This diff is collapsed.
Click to expand it.
mongoose.c
View file @
d333c3c0
...
...
@@ -5532,6 +5532,40 @@ static void handle_propfind(struct mg_connection *nc, const char *path,
}
}
#ifdef MG_ENABLE_FAKE_DAVLOCK
/*
* Windows explorer (probably there are another WebDav clients like it)
* requires LOCK support in webdav. W/out this, it still works, but fails
* to save file: shows error message and offers "Save As".
* "Save as" works, but this message is very annoying.
* This is fake lock, which doesn't lock something, just returns LOCK token,
* UNLOCK always answers "OK".
* With this fake LOCK Windows Explorer looks happy and saves file.
* NOTE: that is not DAV LOCK imlementation, it is just a way to shut up
* Windows native DAV client. This is why FAKE LOCK is not enabed by default
*/
static
void
handle_lock
(
struct
mg_connection
*
nc
,
const
char
*
path
)
{
static
const
char
*
reply
=
"HTTP/1.1 207 Multi-Status
\r\n
"
"Connection: close
\r\n
"
"Content-Type: text/xml; charset=utf-8
\r\n\r\n
"
"<?xml version=
\"
1.0
\"
encoding=
\"
utf-8
\"
?>"
"<d:multistatus xmlns:d='DAV:'>
\n
"
"<D:lockdiscovery>
\n
"
"<D:activelock>
\n
"
"<D:locktoken>
\n
"
"<D:href>
\n
"
"opaquelocktoken:%s%u"
"</D:href>"
"</D:locktoken>"
"</D:activelock>
\n
"
"</D:lockdiscovery>"
"</d:multistatus>
\n
"
;
mg_printf
(
nc
,
reply
,
path
,
(
unsigned
int
)
time
(
NULL
));
nc
->
flags
|=
MG_F_SEND_AND_CLOSE
;
}
#endif
static
void
handle_mkcol
(
struct
mg_connection
*
nc
,
const
char
*
path
,
struct
http_message
*
hm
)
{
int
status_code
=
500
;
...
...
@@ -5679,8 +5713,21 @@ static void handle_put(struct mg_connection *nc, const char *path,
#endif
/* MG_DISABLE_DAV */
static
int
is_dav_request
(
const
struct
mg_str
*
s
)
{
return
!
mg_vcmp
(
s
,
"PUT"
)
||
!
mg_vcmp
(
s
,
"DELETE"
)
||
!
mg_vcmp
(
s
,
"MKCOL"
)
||
!
mg_vcmp
(
s
,
"PROPFIND"
)
||
!
mg_vcmp
(
s
,
"MOVE"
);
static
const
char
*
methods
[]
=
{
"PUT"
,
"DELETE"
,
"MKCOL"
,
"PROPFIND"
,
"MOVE"
#ifdef MG_ENABLE_FAKE_DAVLOCK
,
"LOCK"
,
"UNLOCK"
#endif
};
size_t
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
methods
);
i
++
)
{
if
(
mg_vcmp
(
s
,
methods
[
i
])
==
0
)
{
return
1
;
}
}
return
0
;
}
/*
...
...
@@ -6374,6 +6421,10 @@ void mg_send_http_file(struct mg_connection *nc, char *path,
handle_put
(
nc
,
path
,
hm
);
}
else
if
(
!
mg_vcmp
(
&
hm
->
method
,
"MOVE"
))
{
handle_move
(
nc
,
opts
,
path
,
hm
);
#ifdef MG_ENABLE_FAKE_DAVLOCK
}
else
if
(
!
mg_vcmp
(
&
hm
->
method
,
"LOCK"
))
{
handle_lock
(
nc
,
path
);
#endif
#endif
}
else
if
(
!
mg_vcmp
(
&
hm
->
method
,
"OPTIONS"
))
{
send_options
(
nc
);
...
...
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