Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sunxiaotianmg
Mozi.HttpEmbedded
提交
1642b2b1
M
Mozi.HttpEmbedded
项目概览
sunxiaotianmg
/
Mozi.HttpEmbedded
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Mozi.HttpEmbedded
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1642b2b1
编写于
9月 18, 2020
作者:
JasonWcx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整命名空间
上级
3f37c053
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
145 addition
and
165 deletion
+145
-165
Mozi.HttpEmbedded/Mozi.HttpEmbedded.csproj
Mozi.HttpEmbedded/Mozi.HttpEmbedded.csproj
+8
-8
Mozi.HttpEmbedded/WebDav/DAVExtensions.cs
Mozi.HttpEmbedded/WebDav/DAVExtensions.cs
+1
-1
Mozi.HttpEmbedded/WebDav/DAVServer.cs
Mozi.HttpEmbedded/WebDav/DAVServer.cs
+1
-2
Mozi.HttpEmbedded/WebDav/Exceptions/ConflictException.cs
Mozi.HttpEmbedded/WebDav/Exceptions/ConflictException.cs
+1
-1
Mozi.HttpEmbedded/WebDav/Exceptions/ForbiddenException.cs
Mozi.HttpEmbedded/WebDav/Exceptions/ForbiddenException.cs
+1
-1
Mozi.HttpEmbedded/WebDav/Exceptions/NotFoundException.cs
Mozi.HttpEmbedded/WebDav/Exceptions/NotFoundException.cs
+1
-1
Mozi.HttpEmbedded/WebDav/Exceptions/UnauthorizedException.cs
Mozi.HttpEmbedded/WebDav/Exceptions/UnauthorizedException.cs
+1
-1
Mozi.HttpEmbedded/WebDav/Exceptions/WebDavException.cs
Mozi.HttpEmbedded/WebDav/Exceptions/WebDavException.cs
+3
-3
Mozi.HttpEmbedded/WebDav/Method/Copy.cs
Mozi.HttpEmbedded/WebDav/Method/Copy.cs
+10
-11
Mozi.HttpEmbedded/WebDav/Method/Delete.cs
Mozi.HttpEmbedded/WebDav/Method/Delete.cs
+0
-1
Mozi.HttpEmbedded/WebDav/Method/Head.cs
Mozi.HttpEmbedded/WebDav/Method/Head.cs
+2
-2
Mozi.HttpEmbedded/WebDav/Method/IMethodHandler.cs
Mozi.HttpEmbedded/WebDav/Method/IMethodHandler.cs
+1
-1
Mozi.HttpEmbedded/WebDav/Method/Lock.cs
Mozi.HttpEmbedded/WebDav/Method/Lock.cs
+6
-7
Mozi.HttpEmbedded/WebDav/Method/MethodHandlerBase.cs
Mozi.HttpEmbedded/WebDav/Method/MethodHandlerBase.cs
+25
-28
Mozi.HttpEmbedded/WebDav/Method/MkCol.cs
Mozi.HttpEmbedded/WebDav/Method/MkCol.cs
+12
-10
Mozi.HttpEmbedded/WebDav/Method/Move.cs
Mozi.HttpEmbedded/WebDav/Method/Move.cs
+16
-10
Mozi.HttpEmbedded/WebDav/Method/Propfind.cs
Mozi.HttpEmbedded/WebDav/Method/Propfind.cs
+9
-10
Mozi.HttpEmbedded/WebDav/Method/Proppatch.cs
Mozi.HttpEmbedded/WebDav/Method/Proppatch.cs
+14
-19
Mozi.HttpEmbedded/WebDav/Method/Put.cs
Mozi.HttpEmbedded/WebDav/Method/Put.cs
+0
-1
Mozi.HttpEmbedded/WebDav/Method/Unlock.cs
Mozi.HttpEmbedded/WebDav/Method/Unlock.cs
+1
-1
Mozi.HttpEmbedded/WebDav/Storage/Base/WebDAVStoreBase.cs
Mozi.HttpEmbedded/WebDav/Storage/Base/WebDAVStoreBase.cs
+1
-1
Mozi.HttpEmbedded/WebDav/Storage/Base/WebDAVStoreDocumentBase.cs
...tpEmbedded/WebDav/Storage/Base/WebDAVStoreDocumentBase.cs
+1
-1
Mozi.HttpEmbedded/WebDav/Storage/Base/WebDAVStoreItemBase.cs
Mozi.HttpEmbedded/WebDav/Storage/Base/WebDAVStoreItemBase.cs
+2
-2
Mozi.HttpEmbedded/WebDav/Storage/DiskStore/DiskStoreCollection.cs
...pEmbedded/WebDav/Storage/DiskStore/DiskStoreCollection.cs
+20
-20
Mozi.HttpEmbedded/WebDav/Storage/DiskStore/DiskStoreDocument.cs
...ttpEmbedded/WebDav/Storage/DiskStore/DiskStoreDocument.cs
+2
-2
Mozi.HttpEmbedded/WebDav/Storage/DiskStore/DiskStoreItem.cs
Mozi.HttpEmbedded/WebDav/Storage/DiskStore/DiskStoreItem.cs
+1
-1
Mozi.HttpEmbedded/WebDav/Storage/IWebDAVStoreCollection.cs
Mozi.HttpEmbedded/WebDav/Storage/IWebDAVStoreCollection.cs
+4
-4
Mozi.HttpEmbedded/WebDav/Utilities/Md5Util.cs
Mozi.HttpEmbedded/WebDav/Utilities/Md5Util.cs
+1
-15
未找到文件。
Mozi.HttpEmbedded/Mozi.HttpEmbedded.csproj
浏览文件 @
1642b2b1
...
@@ -103,11 +103,11 @@
...
@@ -103,11 +103,11 @@
<Compile
Include=
"StatusCode.cs"
/>
<Compile
Include=
"StatusCode.cs"
/>
<Compile
Include=
"Encode\StringEncoder.cs"
/>
<Compile
Include=
"Encode\StringEncoder.cs"
/>
<Compile
Include=
"TransformHeader.cs"
/>
<Compile
Include=
"TransformHeader.cs"
/>
<Compile
Include=
"WebDav\Exception\ConflictException.cs"
/>
<Compile
Include=
"WebDav\Exception
s
\ConflictException.cs"
/>
<Compile
Include=
"WebDav\Exception\WebDavException.cs"
/>
<Compile
Include=
"WebDav\Exception
s
\WebDavException.cs"
/>
<Compile
Include=
"WebDav\Exception\ForbiddenException.cs"
/>
<Compile
Include=
"WebDav\Exception
s
\ForbiddenException.cs"
/>
<Compile
Include=
"WebDav\Exception\NotFoundException.cs"
/>
<Compile
Include=
"WebDav\Exception
s
\NotFoundException.cs"
/>
<Compile
Include=
"WebDav\Exception\UnauthorizedException.cs"
/>
<Compile
Include=
"WebDav\Exception
s
\UnauthorizedException.cs"
/>
<Compile
Include=
"WebDav\LockProperty.cs"
/>
<Compile
Include=
"WebDav\LockProperty.cs"
/>
<Compile
Include=
"WebDav\Method\Copy.cs"
/>
<Compile
Include=
"WebDav\Method\Copy.cs"
/>
<Compile
Include=
"WebDav\Method\Delete.cs"
/>
<Compile
Include=
"WebDav\Method\Delete.cs"
/>
...
@@ -121,9 +121,9 @@
...
@@ -121,9 +121,9 @@
<Compile
Include=
"WebDav\Method\Put.cs"
/>
<Compile
Include=
"WebDav\Method\Put.cs"
/>
<Compile
Include=
"WebDav\Method\Unlock.cs"
/>
<Compile
Include=
"WebDav\Method\Unlock.cs"
/>
<Compile
Include=
"WebDav\Method\MethodHandlerBase.cs"
/>
<Compile
Include=
"WebDav\Method\MethodHandlerBase.cs"
/>
<Compile
Include=
"WebDav\Storage\Base
Classes
\WebDAVStoreBase.cs"
/>
<Compile
Include=
"WebDav\Storage\Base\WebDAVStoreBase.cs"
/>
<Compile
Include=
"WebDav\Storage\Base
Classes
\WebDAVStoreDocumentBase.cs"
/>
<Compile
Include=
"WebDav\Storage\Base\WebDAVStoreDocumentBase.cs"
/>
<Compile
Include=
"WebDav\Storage\Base
Classes
\WebDAVStoreItemBase.cs"
/>
<Compile
Include=
"WebDav\Storage\Base\WebDAVStoreItemBase.cs"
/>
<Compile
Include=
"WebDav\Storage\DiskStore\WebDAVDiskStore.cs"
/>
<Compile
Include=
"WebDav\Storage\DiskStore\WebDAVDiskStore.cs"
/>
<Compile
Include=
"WebDav\Storage\DiskStore\DiskStoreCollection.cs"
/>
<Compile
Include=
"WebDav\Storage\DiskStore\DiskStoreCollection.cs"
/>
<Compile
Include=
"WebDav\Storage\DiskStore\DiskStoreDocument.cs"
/>
<Compile
Include=
"WebDav\Storage\DiskStore\DiskStoreDocument.cs"
/>
...
...
Mozi.HttpEmbedded/WebDav/DAVExtensions.cs
浏览文件 @
1642b2b1
using
System
;
using
System
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Exception
;
using
Mozi.HttpEmbedded.WebDav.Exception
s
;
namespace
Mozi.HttpEmbedded.WebDav
namespace
Mozi.HttpEmbedded.WebDav
{
{
...
...
Mozi.HttpEmbedded/WebDav/DAVServer.cs
浏览文件 @
1642b2b1
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
Mozi.HttpEmbedded.WebDav.Exception
;
using
Mozi.HttpEmbedded.WebDav.Exception
s
;
using
Mozi.HttpEmbedded.WebDav.Method
;
using
Mozi.HttpEmbedded.WebDav.Method
;
using
Mozi.HttpEmbedded.WebDav.MethodHandlers
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage.DiskStore
;
using
Mozi.HttpEmbedded.WebDav.Storage.DiskStore
;
...
...
Mozi.HttpEmbedded/WebDav/Exception/ConflictException.cs
→
Mozi.HttpEmbedded/WebDav/Exception
s
/ConflictException.cs
浏览文件 @
1642b2b1
using
System
;
using
System
;
namespace
Mozi.HttpEmbedded.WebDav.Exception
namespace
Mozi.HttpEmbedded.WebDav.Exception
s
{
{
/// <summary>
/// <summary>
/// 409
/// 409
...
...
Mozi.HttpEmbedded/WebDav/Exception/ForbiddenException.cs
→
Mozi.HttpEmbedded/WebDav/Exception
s
/ForbiddenException.cs
浏览文件 @
1642b2b1
using
System
;
using
System
;
namespace
Mozi.HttpEmbedded.WebDav.Exception
namespace
Mozi.HttpEmbedded.WebDav.Exception
s
{
{
/// <summary>
/// <summary>
/// 403
/// 403
...
...
Mozi.HttpEmbedded/WebDav/Exception/NotFoundException.cs
→
Mozi.HttpEmbedded/WebDav/Exception
s
/NotFoundException.cs
浏览文件 @
1642b2b1
using
System
;
using
System
;
namespace
Mozi.HttpEmbedded.WebDav.Exception
namespace
Mozi.HttpEmbedded.WebDav.Exception
s
{
{
/// <summary>
/// <summary>
/// 404
/// 404
...
...
Mozi.HttpEmbedded/WebDav/Exception/UnauthorizedException.cs
→
Mozi.HttpEmbedded/WebDav/Exception
s
/UnauthorizedException.cs
浏览文件 @
1642b2b1
using
System
;
using
System
;
namespace
Mozi.HttpEmbedded.WebDav.Exception
namespace
Mozi.HttpEmbedded.WebDav.Exception
s
{
{
/// <summary>
/// <summary>
///
///
...
...
Mozi.HttpEmbedded/WebDav/Exception/WebDavException.cs
→
Mozi.HttpEmbedded/WebDav/Exception
s
/WebDavException.cs
浏览文件 @
1642b2b1
using
System
;
using
System
;
namespace
Mozi.HttpEmbedded.WebDav.Exception
namespace
Mozi.HttpEmbedded.WebDav.Exception
s
{
{
/// <summary>
/// <summary>
/// </summary>
/// </summary>
[
Serializable
]
[
Serializable
]
public
class
WebDavException
:
Exception
public
class
WebDavException
:
System
.
Exception
{
{
private
StatusCode
_status
;
private
StatusCode
_status
;
private
string
message
;
private
string
message
;
public
override
string
Message
{
get
;
}
public
override
string
Message
{
get
;
}
public
WebDavException
(
StatusCode
status
,
string
message
,
Exception
innerException
)
public
WebDavException
(
StatusCode
status
,
string
message
,
System
.
Exception
innerException
)
{
{
_status
=
status
;
_status
=
status
;
Message
=
message
;
Message
=
message
;
...
...
Mozi.HttpEmbedded/WebDav/Method/Copy.cs
浏览文件 @
1642b2b1
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.WebDav.MethodHandlers
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
namespace
Mozi.HttpEmbedded.WebDav.Method
namespace
Mozi.HttpEmbedded.WebDav.Method
...
@@ -23,27 +22,27 @@ namespace Mozi.HttpEmbedded.WebDav.Method
...
@@ -23,27 +22,27 @@ namespace Mozi.HttpEmbedded.WebDav.Method
IWebDavStoreItem
source
=
WebDavExtensions
.
GetStoreItem
(
context
.
Request
.
Path
,
store
);
IWebDavStoreItem
source
=
WebDavExtensions
.
GetStoreItem
(
context
.
Request
.
Path
,
store
);
if
(
source
is
IWebDavStoreDocument
||
source
is
IWebDavStoreCollection
)
if
(
source
is
IWebDavStoreDocument
||
source
is
IWebDavStoreCollection
)
{
{
string
dest
inationUri
=
context
.
Request
.
Headers
[
"Destination
"
];
string
dest
Path
=
context
.
Request
.
Headers
[
"destItem
"
];
IWebDavStoreCollection
dest
inationParentCollection
=
GetParentCollection
(
store
,
destinationUri
);
IWebDavStoreCollection
dest
ParentCollection
=
GetParentCollection
(
store
,
destPath
);
bool
copyContent
=
GetDepthHeader
(
context
.
Request
)
!=
0
;
bool
copyContent
=
GetDepthHeader
(
context
.
Request
)
!=
0
;
bool
isNew
=
true
;
bool
isNew
=
true
;
UrlTree
ut
=
new
UrlTree
(
dest
inationUri
);
UrlTree
ut
=
new
UrlTree
(
dest
Path
);
string
dest
ination
Name
=
UrlEncoder
.
Decode
(
ut
.
Last
().
TrimEnd
(
'/'
,
'\\'
));
string
destName
=
UrlEncoder
.
Decode
(
ut
.
Last
().
TrimEnd
(
'/'
,
'\\'
));
IWebDavStoreItem
dest
ination
=
destinationParentCollection
.
GetItemByName
(
destination
Name
);
IWebDavStoreItem
dest
Item
=
destParentCollection
.
GetItemByName
(
dest
Name
);
if
(
dest
ination
!=
null
)
if
(
dest
Item
!=
null
)
{
{
if
(
source
.
ItemPath
==
dest
ination
.
ItemPath
)
if
(
source
.
ItemPath
==
dest
Item
.
ItemPath
)
return
StatusCode
.
Forbidden
;
return
StatusCode
.
Forbidden
;
if
(!
GetOverwriteHeader
(
context
.
Request
))
if
(!
GetOverwriteHeader
(
context
.
Request
))
return
StatusCode
.
PreconditionFailed
;
return
StatusCode
.
PreconditionFailed
;
if
(
dest
ination
is
IWebDavStoreCollection
)
if
(
dest
Item
is
IWebDavStoreCollection
)
dest
inationParentCollection
.
Delete
(
destination
);
dest
ParentCollection
.
Delete
(
destItem
);
isNew
=
false
;
isNew
=
false
;
}
}
dest
inationParentCollection
.
CopyItemHere
(
source
,
destination
Name
,
copyContent
);
dest
ParentCollection
.
CopyItemHere
(
source
,
dest
Name
,
copyContent
);
return
isNew
?
StatusCode
.
Created
:
StatusCode
.
NoContent
;
return
isNew
?
StatusCode
.
Created
:
StatusCode
.
NoContent
;
}
}
else
else
...
...
Mozi.HttpEmbedded/WebDav/Method/Delete.cs
浏览文件 @
1642b2b1
using
Mozi.HttpEmbedded.WebDav.MethodHandlers
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
namespace
Mozi.HttpEmbedded.WebDav.Method
namespace
Mozi.HttpEmbedded.WebDav.Method
...
...
Mozi.HttpEmbedded/WebDav/Method/Head.cs
浏览文件 @
1642b2b1
using
Mozi.HttpEmbedded.Source
;
using
Mozi.HttpEmbedded.Source
;
using
Mozi.HttpEmbedded.WebDav.Exception
;
using
Mozi.HttpEmbedded.WebDav.Exception
s
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
namespace
Mozi.HttpEmbedded.WebDav.Method
Handlers
namespace
Mozi.HttpEmbedded.WebDav.Method
{
{
/// <summary>
/// <summary>
/// <c>PROPFIND</c> WebDAV윈嵐렘랬
/// <c>PROPFIND</c> WebDAV윈嵐렘랬
...
...
Mozi.HttpEmbedded/WebDav/Method/IMethodHandler.cs
浏览文件 @
1642b2b1
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
namespace
Mozi.HttpEmbedded.WebDav.Method
Handlers
namespace
Mozi.HttpEmbedded.WebDav.Method
{
{
/// <summary>
/// <summary>
/// </summary>
/// </summary>
...
...
Mozi.HttpEmbedded/WebDav/Method/Lock.cs
浏览文件 @
1642b2b1
using
System
;
using
System
;
using
System.Text
;
using
System.Xml
;
using
System.Xml
;
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
namespace
Mozi.HttpEmbedded.WebDav.Method
Handlers
namespace
Mozi.HttpEmbedded.WebDav.Method
{
{
/// <summary>
/// <summary>
/// <c>LOCK</c> WebDAV扩展方法
/// <c>LOCK</c> WebDAV扩展方法
...
@@ -88,8 +87,8 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -88,8 +87,8 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
collection
.
CreateDocument
(
ut
.
Last
().
TrimEnd
(
'/'
,
'\\'
));
collection
.
CreateDocument
(
ut
.
Last
().
TrimEnd
(
'/'
,
'\\'
));
isNew
=
true
;
isNew
=
true
;
}
}
/***************************************************************************************************
/***************************************************************************************************
* Create the body for the response
* Create the body for the response
...
@@ -97,7 +96,7 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -97,7 +96,7 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
//实例化XML文档
//实例化XML文档
XmlDocument
responseDoc
=
new
XmlDocument
();
XmlDocument
responseDoc
=
new
XmlDocument
();
string
responseXml
=
"<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:prop "
+
"xmlns:D=\"DAV:\"><D:lockdiscovery><D:activelock/></D:lockdiscovery></D:prop>"
;
string
responseXml
=
"<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:prop "
+
"xmlns:D=\"DAV:\"><D:lockdiscovery><D:activelock/></D:lockdiscovery></D:prop>"
;
responseDoc
.
LoadXml
(
responseXml
);
responseDoc
.
LoadXml
(
responseXml
);
//锁定节点
//锁定节点
...
@@ -113,9 +112,9 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -113,9 +112,9 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
activelock
.
AppendChild
(
timeoutProperty
.
ToXmlElement
(
responseDoc
));
activelock
.
AppendChild
(
timeoutProperty
.
ToXmlElement
(
responseDoc
));
// depth头属性
// depth头属性
WebDavProperty
depthProperty
=
new
WebDavProperty
(
"depth"
,
(
depth
==
0
?
"0"
:
"Infinity"
)
);
WebDavProperty
depthProperty
=
new
WebDavProperty
(
"depth"
,
depth
==
0
?
"0"
:
"Infinity"
);
activelock
.
AppendChild
(
depthProperty
.
ToXmlElement
(
responseDoc
));
activelock
.
AppendChild
(
depthProperty
.
ToXmlElement
(
responseDoc
));
// locktoken头属性
// locktoken头属性
WebDavProperty
locktokenProperty
=
new
WebDavProperty
(
"locktoken"
,
""
);
WebDavProperty
locktokenProperty
=
new
WebDavProperty
(
"locktoken"
,
""
);
XmlElement
locktokenElement
=
locktokenProperty
.
ToXmlElement
(
responseDoc
);
XmlElement
locktokenElement
=
locktokenProperty
.
ToXmlElement
(
responseDoc
);
...
...
Mozi.HttpEmbedded/WebDav/Method/MethodHandlerBase.cs
浏览文件 @
1642b2b1
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Exception
;
using
Mozi.HttpEmbedded.WebDav.Exception
s
;
namespace
Mozi.HttpEmbedded.WebDav.Method
Handlers
namespace
Mozi.HttpEmbedded.WebDav.Method
{
{
/// <summary>
/// <summary>
/// </summary>
/// </summary>
...
@@ -21,9 +21,9 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -21,9 +21,9 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
}
}
catch
(
UnauthorizedAccessException
)
catch
(
UnauthorizedAccessException
)
{
{
throw
new
WebDavUnauthorizedException
();
throw
new
WebDavUnauthorizedException
();
}
}
catch
(
WebDavNotFoundException
)
catch
(
WebDavNotFoundException
)
{
{
throw
new
WebDavConflictException
();
throw
new
WebDavConflictException
();
}
}
...
@@ -51,32 +51,30 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -51,32 +51,30 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
{
{
throw
new
WebDavNotFoundException
();
throw
new
WebDavNotFoundException
();
}
}
if
(
item
==
null
)
if
(
item
!=
null
)
throw
new
WebDavNotFoundException
();
{
return
item
;
return
item
;
}
throw
new
WebDavNotFoundException
();
}
}
public
static
int
GetDepthHeader
(
HttpRequest
request
)
public
static
int
GetDepthHeader
(
HttpRequest
request
)
{
{
string
depth
=
request
.
Headers
[
"Depth"
];
string
depth
=
request
.
Headers
[
"Depth"
];
if
(
string
.
IsNullOrEmpty
(
depth
)
||
depth
.
Equals
(
"infinity"
))
if
(!
string
.
IsNullOrEmpty
(
depth
)
&&
!
depth
.
Equals
(
"infinity"
))
{
return
DepthInfinity
;
}
int
value
;
if
(!
int
.
TryParse
(
depth
,
out
value
))
{
{
int
value
;
if
(
int
.
TryParse
(
depth
,
out
value
))
{
if
(
value
==
0
||
value
==
1
)
{
return
value
;
}
return
DepthInfinity
;
}
return
DepthInfinity
;
return
DepthInfinity
;
}
}
if
(
value
==
0
||
value
==
1
)
{
return
value
;
}
return
DepthInfinity
;
return
DepthInfinity
;
}
}
...
@@ -98,15 +96,14 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -98,15 +96,14 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
}
}
return
timeout
;
return
timeout
;
}
}
public
static
Uri
Get
Destination
Header
(
HttpRequest
request
)
public
static
Uri
Get
destItem
Header
(
HttpRequest
request
)
{
{
string
dest
inationUri
=
request
.
Headers
[
"Destination
"
];
string
dest
Path
=
request
.
Headers
[
"destItem
"
];
if
(!
string
.
IsNullOrEmpty
(
destinationUri
))
if
(
string
.
IsNullOrEmpty
(
destPath
))
return
new
Uri
(
destinationUri
);
throw
new
WebDavConflictException
();
return
new
Uri
(
destPath
);
throw
new
WebDavConflictException
();
}
}
}
}
}
}
Mozi.HttpEmbedded/WebDav/Method/MkCol.cs
浏览文件 @
1642b2b1
...
@@ -2,7 +2,7 @@ using Mozi.HttpEmbedded.Common;
...
@@ -2,7 +2,7 @@ using Mozi.HttpEmbedded.Common;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
namespace
Mozi.HttpEmbedded.WebDav.Method
Handlers
namespace
Mozi.HttpEmbedded.WebDav.Method
{
{
/// <summary>
/// <summary>
/// <c>MKCOL</c> WebDAVչ
/// <c>MKCOL</c> WebDAVչ
...
@@ -19,17 +19,19 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -19,17 +19,19 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
/// <param name="store"><see cref="IWebDavStore" /> <see cref="DavServer" /></param>
/// <param name="store"><see cref="IWebDavStore" /> <see cref="DavServer" /></param>
public
StatusCode
ProcessRequest
(
DavServer
server
,
HttpContext
context
,
IWebDavStore
store
)
public
StatusCode
ProcessRequest
(
DavServer
server
,
HttpContext
context
,
IWebDavStore
store
)
{
{
if
(
context
.
Request
.
Body
.
Length
>
0
)
if
(
context
.
Request
.
Body
.
Length
==
0
)
return
StatusCode
.
UnsupportedMediaType
;
{
IWebDavStoreCollection
collection
=
GetParentCollection
(
store
,
context
.
Request
.
Path
.
Replace
(
"/"
,
"\\"
));
IWebDavStoreCollection
collection
=
GetParentCollection
(
store
,
context
.
Request
.
Path
.
Replace
(
"/"
,
"\\"
));
UrlTree
ut
=
new
UrlTree
(
context
.
Request
.
Path
);
UrlTree
ut
=
new
UrlTree
(
context
.
Request
.
Path
);
string
collectionName
=
UrlEncoder
.
Decode
(
ut
.
Last
().
TrimEnd
(
'/'
,
'\\'
));
string
collectionName
=
UrlEncoder
.
Decode
(
ut
.
Last
().
TrimEnd
(
'/'
,
'\\'
));
if
(
collection
.
GetItemByName
(
collectionName
)
!=
null
)
if
(
collection
.
GetItemByName
(
collectionName
)
!=
null
)
return
StatusCode
.
MethodNotAllowed
;
return
StatusCode
.
MethodNotAllowed
;
collection
.
CreateCollection
(
collectionName
);
collection
.
CreateCollection
(
collectionName
);
return
StatusCode
.
Success
;
return
StatusCode
.
Success
;
}
return
StatusCode
.
UnsupportedMediaType
;
}
}
}
}
}
}
\ No newline at end of file
Mozi.HttpEmbedded/WebDav/Method/Move.cs
浏览文件 @
1642b2b1
...
@@ -2,7 +2,7 @@ using Mozi.HttpEmbedded.Common;
...
@@ -2,7 +2,7 @@ using Mozi.HttpEmbedded.Common;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
namespace
Mozi.HttpEmbedded.WebDav.Method
Handlers
namespace
Mozi.HttpEmbedded.WebDav.Method
{
{
/// <summary>
/// <summary>
/// <c>MOVE</c> WebDAVչ
/// <c>MOVE</c> WebDAVչ
...
@@ -21,24 +21,30 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -21,24 +21,30 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
{
{
var
source
=
WebDavExtensions
.
GetStoreItem
(
context
.
Request
.
Path
,
store
);
var
source
=
WebDavExtensions
.
GetStoreItem
(
context
.
Request
.
Path
,
store
);
string
dest
inationUri
=
context
.
Request
.
Headers
[
"Destination
"
];
string
dest
Path
=
context
.
Request
.
Headers
[
"destItem
"
];
IWebDavStoreCollection
dest
inationParentCollection
=
GetParentCollection
(
store
,
destinationUri
);
IWebDavStoreCollection
dest
ParentCollection
=
GetParentCollection
(
store
,
destPath
);
bool
isNew
=
true
;
bool
isNew
=
true
;
UrlTree
ut
=
new
UrlTree
(
dest
inationUri
);
UrlTree
ut
=
new
UrlTree
(
dest
Path
);
string
dest
ination
Name
=
UrlEncoder
.
Decode
(
ut
.
Last
().
TrimEnd
(
'/'
,
'\\'
));
string
destName
=
UrlEncoder
.
Decode
(
ut
.
Last
().
TrimEnd
(
'/'
,
'\\'
));
IWebDavStoreItem
dest
ination
=
destinationParentCollection
.
GetItemByName
(
destination
Name
);
IWebDavStoreItem
dest
Item
=
destParentCollection
.
GetItemByName
(
dest
Name
);
if
(
dest
ination
!=
null
)
if
(
dest
Item
!=
null
)
{
{
if
(
source
.
ItemPath
==
destination
.
ItemPath
)
if
(
source
.
ItemPath
==
destItem
.
ItemPath
)
{
return
StatusCode
.
Forbidden
;
return
StatusCode
.
Forbidden
;
}
if
(!
GetOverwriteHeader
(
context
.
Request
))
if
(!
GetOverwriteHeader
(
context
.
Request
))
{
return
StatusCode
.
PreconditionFailed
;
return
StatusCode
.
PreconditionFailed
;
destinationParentCollection
.
Delete
(
destination
);
}
destParentCollection
.
Delete
(
destItem
);
isNew
=
false
;
isNew
=
false
;
}
}
dest
inationParentCollection
.
MoveItemHere
(
source
,
destination
Name
);
dest
ParentCollection
.
MoveItemHere
(
source
,
dest
Name
);
return
StatusCode
.
Success
;
return
StatusCode
.
Success
;
}
}
...
...
Mozi.HttpEmbedded/WebDav/Method/Propfind.cs
浏览文件 @
1642b2b1
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Xml
;
using
System.Xml
;
using
Mozi.HttpEmbedded.WebDav.MethodHandlers
;
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Exception
;
using
Mozi.HttpEmbedded.WebDav.Exception
s
;
namespace
Mozi.HttpEmbedded.WebDav.Method
namespace
Mozi.HttpEmbedded.WebDav.Method
{
{
...
@@ -15,7 +14,7 @@ namespace Mozi.HttpEmbedded.WebDav.Method
...
@@ -15,7 +14,7 @@ namespace Mozi.HttpEmbedded.WebDav.Method
internal
class
Propfind
:
MethodHandlerBase
,
IMethodHandler
internal
class
Propfind
:
MethodHandlerBase
,
IMethodHandler
{
{
private
string
_requestUri
;
private
string
_requestUri
;
private
List
<
WebDavProperty
>
_req
uestedPropertie
s
;
private
List
<
WebDavProperty
>
_req
Prop
s
;
private
List
<
IWebDavStoreItem
>
_webDavStoreItems
;
private
List
<
IWebDavStoreItem
>
_webDavStoreItems
;
/// <summary>
/// <summary>
...
@@ -46,7 +45,7 @@ namespace Mozi.HttpEmbedded.WebDav.Method
...
@@ -46,7 +45,7 @@ namespace Mozi.HttpEmbedded.WebDav.Method
XmlDocument
requestDoc
=
GetXmlDocument
(
context
.
Request
);
XmlDocument
requestDoc
=
GetXmlDocument
(
context
.
Request
);
//提取请求信息
//提取请求信息
_req
uestedPropertie
s
=
new
List
<
WebDavProperty
>();
_req
Prop
s
=
new
List
<
WebDavProperty
>();
if
(
requestDoc
.
DocumentElement
!=
null
)
if
(
requestDoc
.
DocumentElement
!=
null
)
{
{
if
(
requestDoc
.
DocumentElement
.
LocalName
!=
"propfind"
)
if
(
requestDoc
.
DocumentElement
.
LocalName
!=
"propfind"
)
...
@@ -61,25 +60,25 @@ namespace Mozi.HttpEmbedded.WebDav.Method
...
@@ -61,25 +60,25 @@ namespace Mozi.HttpEmbedded.WebDav.Method
switch
(
n
.
LocalName
)
switch
(
n
.
LocalName
)
{
{
case
"allprop"
:
case
"allprop"
:
_req
uestedPropertie
s
=
GetAllProperties
();
_req
Prop
s
=
GetAllProperties
();
break
;
break
;
case
"propname"
:
case
"propname"
:
isPropname
=
true
;
isPropname
=
true
;
_req
uestedPropertie
s
=
GetAllProperties
();
_req
Prop
s
=
GetAllProperties
();
break
;
break
;
case
"prop"
:
case
"prop"
:
foreach
(
XmlNode
child
in
n
.
ChildNodes
)
foreach
(
XmlNode
child
in
n
.
ChildNodes
)
_req
uestedPropertie
s
.
Add
(
new
WebDavProperty
(
child
.
LocalName
,
""
,
child
.
NamespaceURI
));
_req
Prop
s
.
Add
(
new
WebDavProperty
(
child
.
LocalName
,
""
,
child
.
NamespaceURI
));
break
;
break
;
default
:
default
:
_req
uestedPropertie
s
.
Add
(
new
WebDavProperty
(
n
.
LocalName
,
""
,
n
.
NamespaceURI
));
_req
Prop
s
.
Add
(
new
WebDavProperty
(
n
.
LocalName
,
""
,
n
.
NamespaceURI
));
break
;
break
;
}
}
}
}
}
}
}
}
else
else
_req
uestedPropertie
s
=
GetAllProperties
();
_req
Prop
s
=
GetAllProperties
();
XmlDocument
responseDoc
=
ResponseDocument
(
context
,
isPropname
,
StatusCode
.
Success
);
XmlDocument
responseDoc
=
ResponseDocument
(
context
,
isPropname
,
StatusCode
.
Success
);
...
@@ -242,7 +241,7 @@ namespace Mozi.HttpEmbedded.WebDav.Method
...
@@ -242,7 +241,7 @@ namespace Mozi.HttpEmbedded.WebDav.Method
WebDavProperty
propProperty
=
new
WebDavProperty
(
"prop"
,
""
);
WebDavProperty
propProperty
=
new
WebDavProperty
(
"prop"
,
""
);
XmlElement
propElement
=
propProperty
.
ToXmlElement
(
responseDoc
);
XmlElement
propElement
=
propProperty
.
ToXmlElement
(
responseDoc
);
foreach
(
WebDavProperty
davProperty
in
_req
uestedPropertie
s
)
foreach
(
WebDavProperty
davProperty
in
_req
Prop
s
)
{
{
propElement
.
AppendChild
(
PropChildElement
(
davProperty
,
responseDoc
,
webDavStoreItem
,
propname
));
propElement
.
AppendChild
(
PropChildElement
(
davProperty
,
responseDoc
,
webDavStoreItem
,
propname
));
}
}
...
...
Mozi.HttpEmbedded/WebDav/Method/Proppatch.cs
浏览文件 @
1642b2b1
using
System
;
using
System
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Xml
;
using
System.Xml
;
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
namespace
Mozi.HttpEmbedded.WebDav.Method
Handlers
namespace
Mozi.HttpEmbedded.WebDav.Method
{
{
/// <summary>
/// <summary>
/// <c>PROPPATCH</c> WebDAV扩展方法
/// <c>PROPPATCH</c> WebDAV扩展方法
...
@@ -25,7 +24,7 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -25,7 +24,7 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
/// <param name="store"><see cref="IWebDavStore" /><see cref="DavServer" /></param>
/// <param name="store"><see cref="IWebDavStore" /><see cref="DavServer" /></param>
public
StatusCode
ProcessRequest
(
DavServer
server
,
HttpContext
context
,
IWebDavStore
store
)
public
StatusCode
ProcessRequest
(
DavServer
server
,
HttpContext
context
,
IWebDavStore
store
)
{
{
string
requestUri
=
context
.
Request
.
Path
;
string
requestUri
=
context
.
Request
.
Path
;
XmlNamespaceManager
manager
=
null
;
XmlNamespaceManager
manager
=
null
;
...
@@ -63,10 +62,6 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -63,10 +62,6 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
Log
.
Warn
(
ex
.
Message
);
Log
.
Warn
(
ex
.
Message
);
}
}
/***************************************************************************************************
* Take action
***************************************************************************************************/
//父目录资源清单
//父目录资源清单
IWebDavStoreCollection
collection
=
GetParentCollection
(
store
,
context
.
Request
.
Path
);
IWebDavStoreCollection
collection
=
GetParentCollection
(
store
,
context
.
Request
.
Path
);
...
@@ -115,20 +110,20 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -115,20 +110,20 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
WebDavProperty
propstatProperty
=
new
WebDavProperty
(
"propstat"
,
""
);
WebDavProperty
propstatProperty
=
new
WebDavProperty
(
"propstat"
,
""
);
XmlElement
propstatElement
=
propstatProperty
.
ToXmlElement
(
responseDoc
);
XmlElement
propstatElement
=
propstatProperty
.
ToXmlElement
(
responseDoc
);
WebDavProperty
statusProperty
=
new
WebDavProperty
(
"status"
,
"HTTP/1.1 "
+
context
.
Response
.
Status
.
Code
+
" "
+
context
.
Response
.
Status
.
Text
);
WebDavProperty
statusProperty
=
new
WebDavProperty
(
"status"
,
"HTTP/1.1 "
+
context
.
Response
.
Status
.
Code
+
" "
+
context
.
Response
.
Status
.
Text
);
propstatElement
.
AppendChild
(
statusProperty
.
ToXmlElement
(
responseDoc
));
propstatElement
.
AppendChild
(
statusProperty
.
ToXmlElement
(
responseDoc
));
foreach
(
WebDavProperty
property
in
from
XmlNode
child
in
propNode
.
ChildNodes
foreach
(
WebDavProperty
property
in
from
XmlNode
child
in
propNode
.
ChildNodes
where
child
.
Name
.
ToLower
()
where
child
.
Name
.
ToLower
()
.
Contains
(
"creationtime"
)
||
child
.
Name
.
ToLower
()
.
Contains
(
"creationtime"
)
||
child
.
Name
.
ToLower
()
.
Contains
(
"fileattributes"
)
||
child
.
Name
.
ToLower
()
.
Contains
(
"fileattributes"
)
||
child
.
Name
.
ToLower
()
.
Contains
(
"lastaccesstime"
)
||
child
.
Name
.
ToLower
()
.
Contains
(
"lastaccesstime"
)
||
child
.
Name
.
ToLower
()
.
Contains
(
"lastmodifiedtime"
)
.
Contains
(
"lastmodifiedtime"
)
let
node
=
propNode
.
SelectSingleNode
(
child
.
Name
,
manager
)
let
node
=
propNode
.
SelectSingleNode
(
child
.
Name
,
manager
)
select
node
!=
null
select
node
!=
null
?
new
WebDavProperty
(
child
.
LocalName
,
""
,
node
.
NamespaceURI
)
?
new
WebDavProperty
(
child
.
LocalName
,
""
,
node
.
NamespaceURI
)
:
new
WebDavProperty
(
child
.
LocalName
,
""
,
""
))
:
new
WebDavProperty
(
child
.
LocalName
,
""
,
""
))
propstatElement
.
AppendChild
(
property
.
ToXmlElement
(
responseDoc
));
propstatElement
.
AppendChild
(
property
.
ToXmlElement
(
responseDoc
));
responseNode
.
AppendChild
(
propstatElement
);
responseNode
.
AppendChild
(
propstatElement
);
...
@@ -137,7 +132,7 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
...
@@ -137,7 +132,7 @@ namespace Mozi.HttpEmbedded.WebDav.MethodHandlers
byte
[]
responseBytes
=
StringEncoder
.
Encode
(
resp
);
byte
[]
responseBytes
=
StringEncoder
.
Encode
(
resp
);
context
.
Response
.
Headers
.
Add
(
HeaderProperty
.
ContentType
.
PropertyTag
,
"text/xml"
);
context
.
Response
.
Headers
.
Add
(
HeaderProperty
.
ContentType
.
PropertyTag
,
"text/xml"
);
context
.
Response
.
Write
(
responseBytes
);
context
.
Response
.
Write
(
responseBytes
);
return
StatusCode
.
MultiStatus
;
return
StatusCode
.
MultiStatus
;
...
...
Mozi.HttpEmbedded/WebDav/Method/Put.cs
浏览文件 @
1642b2b1
using
System.IO
;
using
System.IO
;
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.Common
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.Encode
;
using
Mozi.HttpEmbedded.WebDav.MethodHandlers
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
namespace
Mozi.HttpEmbedded.WebDav.Method
namespace
Mozi.HttpEmbedded.WebDav.Method
...
...
Mozi.HttpEmbedded/WebDav/Method/Unlock.cs
浏览文件 @
1642b2b1
using
Mozi.HttpEmbedded.WebDav.Storage
;
using
Mozi.HttpEmbedded.WebDav.Storage
;
namespace
Mozi.HttpEmbedded.WebDav.Method
Handlers
namespace
Mozi.HttpEmbedded.WebDav.Method
{
{
/// <summary>
/// <summary>
/// <c>PUT</c> WebDAV扩展方法
/// <c>PUT</c> WebDAV扩展方法
...
...
Mozi.HttpEmbedded/WebDav/Storage/Base
Classes
/WebDAVStoreBase.cs
→
Mozi.HttpEmbedded/WebDav/Storage/Base/WebDAVStoreBase.cs
浏览文件 @
1642b2b1
using
System
;
using
System
;
namespace
Mozi.HttpEmbedded.WebDav.Storage.Base
Classes
namespace
Mozi.HttpEmbedded.WebDav.Storage.Base
{
{
/// <summary>
/// <summary>
/// This class is a base class for <see cref="IWebDavStore" /> implementations.
/// This class is a base class for <see cref="IWebDavStore" /> implementations.
...
...
Mozi.HttpEmbedded/WebDav/Storage/Base
Classes
/WebDAVStoreDocumentBase.cs
→
Mozi.HttpEmbedded/WebDav/Storage/Base/WebDAVStoreDocumentBase.cs
浏览文件 @
1642b2b1
using
Mozi.HttpEmbedded.Source
;
using
Mozi.HttpEmbedded.Source
;
using
System
;
using
System
;
namespace
Mozi.HttpEmbedded.WebDav.Storage.Base
Classes
namespace
Mozi.HttpEmbedded.WebDav.Storage.Base
{
{
/// <summary>
/// <summary>
/// This is the base class for <see cref="IWebDavStoreItem" /> implementations.
/// This is the base class for <see cref="IWebDavStoreItem" /> implementations.
...
...
Mozi.HttpEmbedded/WebDav/Storage/Base
Classes
/WebDAVStoreItemBase.cs
→
Mozi.HttpEmbedded/WebDav/Storage/Base/WebDAVStoreItemBase.cs
浏览文件 @
1642b2b1
using
Mozi.HttpEmbedded.WebDav.Exception
;
using
Mozi.HttpEmbedded.WebDav.Exception
s
;
using
System
;
using
System
;
namespace
Mozi.HttpEmbedded.WebDav.Storage.Base
Classes
namespace
Mozi.HttpEmbedded.WebDav.Storage.Base
{
{
/// <summary>
/// <summary>
/// This is the base class for <see cref="IWebDavStoreItem" /> implementations.
/// This is the base class for <see cref="IWebDavStoreItem" /> implementations.
...
...
Mozi.HttpEmbedded/WebDav/Storage/DiskStore/DiskStoreCollection.cs
浏览文件 @
1642b2b1
using
Mozi.HttpEmbedded.WebDav.Exception
;
using
Mozi.HttpEmbedded.WebDav.Exception
s
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Diagnostics
;
...
@@ -325,22 +325,22 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -325,22 +325,22 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
/// Copies an existing store item into this collection, overwriting any existing items.
/// Copies an existing store item into this collection, overwriting any existing items.
/// </summary>
/// </summary>
/// <param name="source">The store item to copy from.</param>
/// <param name="source">The store item to copy from.</param>
/// <param name="dest
ination
Name">The name of the copy to create of <paramref name="source" />.</param>
/// <param name="destName">The name of the copy to create of <paramref name="source" />.</param>
/// <param name="includeContent">The boolean for copying the containing files/folders or not.</param>
/// <param name="includeContent">The boolean for copying the containing files/folders or not.</param>
/// <returns>
/// <returns>
/// The created <see cref="IWebDavStoreItem" /> instance.
/// The created <see cref="IWebDavStoreItem" /> instance.
/// </returns>
/// </returns>
/// <exception cref="WebDavUnauthorizedException">If the user is unauthorized or has no access</exception>
/// <exception cref="WebDavUnauthorizedException">If the user is unauthorized or has no access</exception>
public
IWebDavStoreItem
CopyItemHere
(
IWebDavStoreItem
source
,
string
dest
ination
Name
,
bool
includeContent
)
public
IWebDavStoreItem
CopyItemHere
(
IWebDavStoreItem
source
,
string
destName
,
bool
includeContent
)
{
{
string
dest
inationItemPath
=
Path
.
Combine
(
ItemPath
,
destination
Name
);
string
dest
ItemItemPath
=
Path
.
Combine
(
ItemPath
,
dest
Name
);
if
(
source
.
IsCollection
)
if
(
source
.
IsCollection
)
{
{
try
try
{
{
WindowsImpersonationContext
wic
=
Identity
.
Impersonate
();
WindowsImpersonationContext
wic
=
Identity
.
Impersonate
();
DirectoryCopy
(
source
.
ItemPath
,
dest
ination
ItemPath
,
true
);
DirectoryCopy
(
source
.
ItemPath
,
dest
Item
ItemPath
,
true
);
wic
.
Undo
();
wic
.
Undo
();
}
}
catch
catch
...
@@ -348,8 +348,8 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -348,8 +348,8 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
throw
new
WebDavUnauthorizedException
();
throw
new
WebDavUnauthorizedException
();
}
}
DiskStoreCollection
collection
=
new
DiskStoreCollection
(
this
,
dest
ination
ItemPath
);
DiskStoreCollection
collection
=
new
DiskStoreCollection
(
this
,
dest
Item
ItemPath
);
_items
.
Add
(
dest
ination
Name
,
new
WeakReference
(
collection
));
_items
.
Add
(
destName
,
new
WeakReference
(
collection
));
return
collection
;
return
collection
;
}
}
...
@@ -357,7 +357,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -357,7 +357,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
try
try
{
{
WindowsImpersonationContext
wic
=
Identity
.
Impersonate
();
WindowsImpersonationContext
wic
=
Identity
.
Impersonate
();
System
.
IO
.
File
.
Copy
(
source
.
ItemPath
,
dest
ination
ItemPath
,
true
);
System
.
IO
.
File
.
Copy
(
source
.
ItemPath
,
dest
Item
ItemPath
,
true
);
wic
.
Undo
();
wic
.
Undo
();
}
}
catch
catch
...
@@ -365,8 +365,8 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -365,8 +365,8 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
throw
new
WebDavUnauthorizedException
();
throw
new
WebDavUnauthorizedException
();
}
}
DiskStoreDocument
document
=
new
DiskStoreDocument
(
this
,
dest
ination
ItemPath
);
DiskStoreDocument
document
=
new
DiskStoreDocument
(
this
,
dest
Item
ItemPath
);
_items
.
Add
(
dest
ination
Name
,
new
WeakReference
(
document
));
_items
.
Add
(
destName
,
new
WeakReference
(
document
));
return
document
;
return
document
;
}
}
...
@@ -392,7 +392,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -392,7 +392,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
+
sourceDirName
);
+
sourceDirName
);
}
}
// If the dest
ination
directory doesn't exist, create it.
// If the dest
Item
directory doesn't exist, create it.
if
(!
Directory
.
Exists
(
destDirName
))
if
(!
Directory
.
Exists
(
destDirName
))
{
{
Directory
.
CreateDirectory
(
destDirName
);
Directory
.
CreateDirectory
(
destDirName
);
...
@@ -413,7 +413,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -413,7 +413,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
/// Moves an existing store item into this collection, overwriting any existing items.
/// Moves an existing store item into this collection, overwriting any existing items.
/// </summary>
/// </summary>
/// <param name="source">The store item to move.</param>
/// <param name="source">The store item to move.</param>
/// <param name="dest
ination
Name">The
/// <param name="destName">The
/// <see cref="IWebDavStoreItem" /> that refers to the item that was moved,
/// <see cref="IWebDavStoreItem" /> that refers to the item that was moved,
/// in its new location.</param>
/// in its new location.</param>
/// <returns>
/// <returns>
...
@@ -425,7 +425,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -425,7 +425,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
/// Note that the method should fail without creating or overwriting content in the
/// Note that the method should fail without creating or overwriting content in the
/// target collection if the move cannot go through.
/// target collection if the move cannot go through.
/// </remarks>
/// </remarks>
public
IWebDavStoreItem
MoveItemHere
(
IWebDavStoreItem
source
,
string
dest
ination
Name
)
public
IWebDavStoreItem
MoveItemHere
(
IWebDavStoreItem
source
,
string
destName
)
{
{
string
sourceItemPath
=
""
;
string
sourceItemPath
=
""
;
...
@@ -438,7 +438,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -438,7 +438,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
}
}
string
dest
inationItemPath
=
Path
.
Combine
(
ItemPath
,
destination
Name
);
string
dest
ItemItemPath
=
Path
.
Combine
(
ItemPath
,
dest
Name
);
if
(
source
.
IsCollection
)
if
(
source
.
IsCollection
)
...
@@ -447,7 +447,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -447,7 +447,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
{
{
WindowsImpersonationContext
wic
=
Identity
.
Impersonate
();
WindowsImpersonationContext
wic
=
Identity
.
Impersonate
();
Directory
.
Move
(
sourceItemPath
,
dest
ination
ItemPath
);
Directory
.
Move
(
sourceItemPath
,
dest
Item
ItemPath
);
wic
.
Undo
();
wic
.
Undo
();
}
}
catch
catch
...
@@ -456,8 +456,8 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -456,8 +456,8 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
}
}
var
collection
=
new
DiskStoreCollection
(
this
,
dest
ination
ItemPath
);
var
collection
=
new
DiskStoreCollection
(
this
,
dest
Item
ItemPath
);
_items
.
Add
(
dest
ination
Name
,
new
WeakReference
(
collection
));
_items
.
Add
(
destName
,
new
WeakReference
(
collection
));
return
collection
;
return
collection
;
}
}
...
@@ -465,7 +465,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -465,7 +465,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
{
{
WindowsImpersonationContext
wic
=
Identity
.
Impersonate
();
WindowsImpersonationContext
wic
=
Identity
.
Impersonate
();
System
.
IO
.
File
.
Move
(
sourceItemPath
,
dest
ination
ItemPath
);
System
.
IO
.
File
.
Move
(
sourceItemPath
,
dest
Item
ItemPath
);
wic
.
Undo
();
wic
.
Undo
();
}
}
catch
catch
...
@@ -474,8 +474,8 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -474,8 +474,8 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
}
}
DiskStoreDocument
document
=
new
DiskStoreDocument
(
this
,
dest
ination
ItemPath
);
DiskStoreDocument
document
=
new
DiskStoreDocument
(
this
,
dest
Item
ItemPath
);
_items
.
Add
(
dest
ination
Name
,
new
WeakReference
(
document
));
_items
.
Add
(
destName
,
new
WeakReference
(
document
));
return
document
;
return
document
;
}
}
...
...
Mozi.HttpEmbedded/WebDav/Storage/DiskStore/DiskStoreDocument.cs
浏览文件 @
1642b2b1
...
@@ -3,7 +3,7 @@ using System.Diagnostics;
...
@@ -3,7 +3,7 @@ using System.Diagnostics;
using
System.IO
;
using
System.IO
;
using
System.Security.Principal
;
using
System.Security.Principal
;
using
Mozi.HttpEmbedded.Source
;
using
Mozi.HttpEmbedded.Source
;
using
Mozi.HttpEmbedded.WebDav.Exception
;
using
Mozi.HttpEmbedded.WebDav.Exception
s
;
using
Mozi.HttpEmbedded.WebDav.Utilities
;
using
Mozi.HttpEmbedded.WebDav.Utilities
;
namespace
Mozi.HttpEmbedded.WebDav.Storage.DiskStore
namespace
Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -59,7 +59,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
...
@@ -59,7 +59,7 @@ namespace Mozi.HttpEmbedded.WebDav.Storage.DiskStore
{
{
get
get
{
{
return
Md5Util
.
Md5Hash
StringFor
Utf8String
(
ItemPath
+
ModificationDate
+
Hidden
+
Size
);
return
Md5Util
.
Md5Hash
4
Utf8String
(
ItemPath
+
ModificationDate
+
Hidden
+
Size
);
}
}
}
}
...
...
Mozi.HttpEmbedded/WebDav/Storage/DiskStore/DiskStoreItem.cs
浏览文件 @
1642b2b1
...
@@ -2,7 +2,7 @@ using System;
...
@@ -2,7 +2,7 @@ using System;
using
System.IO
;
using
System.IO
;
using
System.Security.Principal
;
using
System.Security.Principal
;
using
System.Threading
;
using
System.Threading
;
using
Mozi.HttpEmbedded.WebDav.Storage.Base
Classes
;
using
Mozi.HttpEmbedded.WebDav.Storage.Base
;
namespace
Mozi.HttpEmbedded.WebDav.Storage.DiskStore
namespace
Mozi.HttpEmbedded.WebDav.Storage.DiskStore
{
{
...
...
Mozi.HttpEmbedded/WebDav/Storage/IWebDAVStoreCollection.cs
浏览文件 @
1642b2b1
...
@@ -58,18 +58,18 @@ namespace Mozi.HttpEmbedded.WebDav.Storage
...
@@ -58,18 +58,18 @@ namespace Mozi.HttpEmbedded.WebDav.Storage
/// Copies an existing store item into this collection, overwriting any existing items.
/// Copies an existing store item into this collection, overwriting any existing items.
/// </summary>
/// </summary>
/// <param name="source">The store item to copy from.</param>
/// <param name="source">The store item to copy from.</param>
/// <param name="dest
ination
Name">The name of the copy to create of <paramref name="source" />.</param>
/// <param name="destName">The name of the copy to create of <paramref name="source" />.</param>
/// <param name="includeContent">The boolean for copying the containing files/folders or not.</param>
/// <param name="includeContent">The boolean for copying the containing files/folders or not.</param>
/// <returns>
/// <returns>
/// The created <see cref="IWebDavStoreItem" /> instance.
/// The created <see cref="IWebDavStoreItem" /> instance.
/// </returns>
/// </returns>
IWebDavStoreItem
CopyItemHere
(
IWebDavStoreItem
source
,
string
dest
ination
Name
,
bool
includeContent
);
IWebDavStoreItem
CopyItemHere
(
IWebDavStoreItem
source
,
string
destName
,
bool
includeContent
);
/// <summary>
/// <summary>
/// Moves an existing store item into this collection, overwriting any existing items.
/// Moves an existing store item into this collection, overwriting any existing items.
/// </summary>
/// </summary>
/// <param name="source">The store item to move.</param>
/// <param name="source">The store item to move.</param>
/// <param name="dest
ination
Name">The
/// <param name="destName">The
/// <see cref="IWebDavStoreItem" /> that refers to the item that was moved,
/// <see cref="IWebDavStoreItem" /> that refers to the item that was moved,
/// in its new location.</param>
/// in its new location.</param>
/// <returns>
/// <returns>
...
@@ -79,6 +79,6 @@ namespace Mozi.HttpEmbedded.WebDav.Storage
...
@@ -79,6 +79,6 @@ namespace Mozi.HttpEmbedded.WebDav.Storage
/// Note that the method should fail without creating or overwriting content in the
/// Note that the method should fail without creating or overwriting content in the
/// target collection if the move cannot go through.
/// target collection if the move cannot go through.
/// </remarks>
/// </remarks>
IWebDavStoreItem
MoveItemHere
(
IWebDavStoreItem
source
,
string
dest
ination
Name
);
IWebDavStoreItem
MoveItemHere
(
IWebDavStoreItem
source
,
string
destName
);
}
}
}
}
\ No newline at end of file
Mozi.HttpEmbedded/WebDav/Utilities/Md5Util.cs
浏览文件 @
1642b2b1
...
@@ -5,15 +5,9 @@ using Mozi.HttpEmbedded.Encode;
...
@@ -5,15 +5,9 @@ using Mozi.HttpEmbedded.Encode;
namespace
Mozi.HttpEmbedded.WebDav.Utilities
namespace
Mozi.HttpEmbedded.WebDav.Utilities
{
{
/// <summary>
/// For generating an MD5 hash
/// </summary>
/// <remarks>
/// Source: <see href="https://gist.github.com/kristopherjohnson/3021045" />
/// </remarks>
internal
static
class
Md5Util
internal
static
class
Md5Util
{
{
public
static
string
Md5Hash
StringFor
Utf8String
(
string
s
)
public
static
string
Md5Hash
4
Utf8String
(
string
s
)
{
{
byte
[]
bytes
=
StringEncoder
.
Encode
(
s
);
byte
[]
bytes
=
StringEncoder
.
Encode
(
s
);
...
@@ -22,14 +16,6 @@ namespace Mozi.HttpEmbedded.WebDav.Utilities
...
@@ -22,14 +16,6 @@ namespace Mozi.HttpEmbedded.WebDav.Utilities
return
HexStringFromBytes
(
hashBytes
);
return
HexStringFromBytes
(
hashBytes
);
}
}
/// <summary>
/// Convert an array of bytes to a string of hex digits
/// </summary>
/// <param name="bytes">Array of bytes</param>
/// <returns>
/// String of hex digits
/// </returns>
public
static
string
HexStringFromBytes
(
byte
[]
bytes
)
public
static
string
HexStringFromBytes
(
byte
[]
bytes
)
{
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录