Skip to content

Commit 7e95e20

Browse files
committed
v6.0.3890-Beta
1 parent 371c077 commit 7e95e20

File tree

238 files changed

+4390
-1496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+4390
-1496
lines changed

CS/CalDAVServer.FileSystemStorage.AspNet/CalDAVServer.FileSystemStorage.AspNet.csproj

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
77
<ProductVersion>9.0.30729</ProductVersion>
88
<SchemaVersion>2.0</SchemaVersion>
9-
<ProjectGuid>DDA95D93-DEBC-4F1D-AD89-D2734B79EF18</ProjectGuid>
9+
<ProjectGuid>11BA861F-27F1-4AB5-9646-4652E86D582E</ProjectGuid>
1010
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
1111
<OutputType>Library</OutputType>
1212
<AppDesignerFolder>Properties</AppDesignerFolder>
@@ -123,10 +123,10 @@
123123
</ItemGroup>
124124
<ItemGroup>
125125
<Reference Include="ITHit.WebDAV.Server">
126-
<HintPath>..\packages\ITHit.WebDAV.Server.5.7.3670\lib\net451\ITHit.WebDAV.Server.dll</HintPath>
126+
<HintPath>..\packages\ITHit.WebDAV.Server.6.0.3890-Beta\lib\net451\ITHit.WebDAV.Server.dll</HintPath>
127127
</Reference>
128128
<Reference Include="ITHit.WebDAV.Server.Web">
129-
<HintPath>..\packages\ITHit.WebDAV.Server.Web.5.7.3670\lib\net451\ITHit.WebDAV.Server.Web.dll</HintPath>
129+
<HintPath>..\packages\ITHit.WebDAV.Server.Web.6.0.3890-Beta\lib\net451\ITHit.WebDAV.Server.Web.dll</HintPath>
130130
</Reference>
131131
</ItemGroup>
132132
<PropertyGroup>
@@ -144,7 +144,7 @@
144144
<AutoAssignPort>True</AutoAssignPort>
145145
<DevelopmentServerPort>9658</DevelopmentServerPort>
146146
<DevelopmentServerVPath>/</DevelopmentServerVPath>
147-
<IISUrl>http://localhost:41833/</IISUrl>
147+
<IISUrl>http://localhost:25831/</IISUrl>
148148
<NTLMAuthentication>True</NTLMAuthentication>
149149
<UseCustomServer>False</UseCustomServer>
150150
<CustomServerUrl>
@@ -154,6 +154,15 @@
154154
</FlavorProperties>
155155
</VisualStudio>
156156
</ProjectExtensions>
157+
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
158+
<Exec Command="&quot;$(DevEnvDir)..\..\Web\External\npm.cmd&quot; install webdav.client --prefix wwwroot/js" ContinueOnError="true" StdOutEncoding="utf-8">
159+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
160+
</Exec>
161+
<Exec Command="npm install webdav.client --prefix wwwroot/js" ContinueOnError="true" Condition="'$(ErrorCode)' == '127' OR '$(ErrorCode)' == '3'" StdOutEncoding="utf-8">
162+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
163+
</Exec>
164+
<Error Text="Node.js Package Manager (NPM) is required to download IT Hit WebDAV Ajax Library package. Install NPM from https://npmjs.com and run build again." Condition="'$(ErrorCode)' == '127' OR '$(ErrorCode)' == '9009'" />
165+
</Target>
157166
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
158167
Other similar extension points exist, see Microsoft.Common.targets.
159168
<Target Name="BeforeBuild">

CS/CalDAVServer.FileSystemStorage.AspNet/MyCustomGetHandler.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,63 @@ public async Task ProcessRequestAsync(DavContextBaseAsync context, IHierarchyIte
104104
await Task.Factory.FromAsync(page.BeginProcessRequest, page.EndProcessRequest, HttpContext.Current, null);
105105
}
106106
}
107+
else if (context.Request.RawUrl.StartsWith("/AjaxFileBrowser/") || context.Request.RawUrl.StartsWith("/wwwroot/"))
108+
{
109+
// The "/AjaxFileBrowser/" is not a WebDAV folder. It can be used to store client script files,
110+
// images, static HTML files or any other files that does not require access via WebDAV.
111+
// Any request to the files in this folder will just serve them to client.
112+
113+
await context.EnsureBeforeResponseWasCalledAsync();
114+
string filePath = Path.Combine(htmlPath, context.Request.RawUrl.TrimStart('/').Replace('/', Path.DirectorySeparatorChar));
115+
116+
// Remove query string.
117+
int queryIndex = filePath.LastIndexOf('?');
118+
if (queryIndex > -1)
119+
{
120+
filePath = filePath.Remove(queryIndex);
121+
}
122+
123+
if (!File.Exists(filePath))
124+
{
125+
throw new DavException("File not found: " + filePath, DavStatus.NOT_FOUND);
126+
}
127+
128+
using (TextReader reader = File.OpenText(filePath))
129+
{
130+
string html = await reader.ReadToEndAsync();
131+
await WriteFileContentAsync(context, html, filePath);
132+
}
133+
}
107134
else
108135
{
109136
await OriginalHandler.ProcessRequestAsync(context, item);
110137
}
111138
}
112139

140+
/// <summary>
141+
/// Writes HTML to the output stream in case of GET request using encoding specified in Engine.
142+
/// Writes headers only in caes of HEAD request.
143+
/// </summary>
144+
/// <param name="context">Instace of <see cref="DavContextBaseAsync"/>.</param>
145+
/// <param name="content">String representation of the content to write.</param>
146+
/// <param name="filePath">Relative file path, which holds the content.</param>
147+
private async Task WriteFileContentAsync(DavContextBaseAsync context, string content, string filePath)
148+
{
149+
string contentType = null;
150+
Encoding encoding = context.Engine.ContentEncoding; // UTF-8 by default
151+
context.Response.ContentLength = encoding.GetByteCount(content);
152+
context.Response.ContentType = $"{MimeMapping.GetMimeMapping(filePath)}; charset={encoding.WebName}";
153+
154+
// Return file content in case of GET request, in case of HEAD just return headers.
155+
if (context.Request.HttpMethod == "GET")
156+
{
157+
using (var writer = new StreamWriter(context.Response.OutputStream, encoding))
158+
{
159+
await writer.WriteAsync(content);
160+
}
161+
}
162+
}
163+
113164
/// <summary>
114165
/// This handler shall only be invoked for <see cref="IFolderAsync"/> items or if original handler (which
115166
/// this handler substitutes) shall be called for the item.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="ITHit.WebDAV.Server" version="5.7.3670" targetFramework="net451" />
4-
<package id="ITHit.WebDAV.Server.Web" version="5.7.3670" targetFramework="net451" />
3+
<package id="ITHit.WebDAV.Server" version="6.0.3890-Beta" targetFramework="net451" />
4+
<package id="ITHit.WebDAV.Server.Web" version="6.0.3890-Beta" targetFramework="net451" />
55
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net451" />
66
</packages>
0 Bytes
Binary file not shown.
Binary file not shown.

CS/CalDAVServer.SqlStorage.AspNet/CalDAVServer.SqlStorage.AspNet.csproj

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
77
<ProductVersion>9.0.30729</ProductVersion>
88
<SchemaVersion>2.0</SchemaVersion>
9-
<ProjectGuid>AD7A9B48-6D36-41B0-97C4-B04421A1D1D0</ProjectGuid>
9+
<ProjectGuid>49AAD352-CE53-4590-9452-A6CAB9465CC1</ProjectGuid>
1010
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
1111
<OutputType>Library</OutputType>
1212
<AppDesignerFolder>Properties</AppDesignerFolder>
@@ -111,10 +111,10 @@
111111
</ItemGroup>
112112
<ItemGroup>
113113
<Reference Include="ITHit.WebDAV.Server">
114-
<HintPath>..\packages\ITHit.WebDAV.Server.5.7.3670\lib\net451\ITHit.WebDAV.Server.dll</HintPath>
114+
<HintPath>..\packages\ITHit.WebDAV.Server.6.0.3890-Beta\lib\net451\ITHit.WebDAV.Server.dll</HintPath>
115115
</Reference>
116116
<Reference Include="ITHit.WebDAV.Server.Web">
117-
<HintPath>..\packages\ITHit.WebDAV.Server.Web.5.7.3670\lib\net451\ITHit.WebDAV.Server.Web.dll</HintPath>
117+
<HintPath>..\packages\ITHit.WebDAV.Server.Web.6.0.3890-Beta\lib\net451\ITHit.WebDAV.Server.Web.dll</HintPath>
118118
</Reference>
119119
</ItemGroup>
120120
<PropertyGroup>
@@ -132,7 +132,7 @@
132132
<AutoAssignPort>True</AutoAssignPort>
133133
<DevelopmentServerPort>9658</DevelopmentServerPort>
134134
<DevelopmentServerVPath>/</DevelopmentServerVPath>
135-
<IISUrl>http://localhost:9296/</IISUrl>
135+
<IISUrl>http://localhost:39897/</IISUrl>
136136
<NTLMAuthentication>False</NTLMAuthentication>
137137
<UseCustomServer>False</UseCustomServer>
138138
<CustomServerUrl>
@@ -142,6 +142,15 @@
142142
</FlavorProperties>
143143
</VisualStudio>
144144
</ProjectExtensions>
145+
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
146+
<Exec Command="&quot;$(DevEnvDir)..\..\Web\External\npm.cmd&quot; install webdav.client --prefix wwwroot/js" ContinueOnError="true" StdOutEncoding="utf-8">
147+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
148+
</Exec>
149+
<Exec Command="npm install webdav.client --prefix wwwroot/js" ContinueOnError="true" Condition="'$(ErrorCode)' == '127' OR '$(ErrorCode)' == '3'" StdOutEncoding="utf-8">
150+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
151+
</Exec>
152+
<Error Text="Node.js Package Manager (NPM) is required to download IT Hit WebDAV Ajax Library package. Install NPM from https://npmjs.com and run build again." Condition="'$(ErrorCode)' == '127' OR '$(ErrorCode)' == '9009'" />
153+
</Target>
145154
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
146155
Other similar extension points exist, see Microsoft.Common.targets.
147156
<Target Name="BeforeBuild">

CS/CalDAVServer.SqlStorage.AspNet/MyCustomGetHandler.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,63 @@ public async Task ProcessRequestAsync(DavContextBaseAsync context, IHierarchyIte
104104
await Task.Factory.FromAsync(page.BeginProcessRequest, page.EndProcessRequest, HttpContext.Current, null);
105105
}
106106
}
107+
else if (context.Request.RawUrl.StartsWith("/AjaxFileBrowser/") || context.Request.RawUrl.StartsWith("/wwwroot/"))
108+
{
109+
// The "/AjaxFileBrowser/" is not a WebDAV folder. It can be used to store client script files,
110+
// images, static HTML files or any other files that does not require access via WebDAV.
111+
// Any request to the files in this folder will just serve them to client.
112+
113+
await context.EnsureBeforeResponseWasCalledAsync();
114+
string filePath = Path.Combine(htmlPath, context.Request.RawUrl.TrimStart('/').Replace('/', Path.DirectorySeparatorChar));
115+
116+
// Remove query string.
117+
int queryIndex = filePath.LastIndexOf('?');
118+
if (queryIndex > -1)
119+
{
120+
filePath = filePath.Remove(queryIndex);
121+
}
122+
123+
if (!File.Exists(filePath))
124+
{
125+
throw new DavException("File not found: " + filePath, DavStatus.NOT_FOUND);
126+
}
127+
128+
using (TextReader reader = File.OpenText(filePath))
129+
{
130+
string html = await reader.ReadToEndAsync();
131+
await WriteFileContentAsync(context, html, filePath);
132+
}
133+
}
107134
else
108135
{
109136
await OriginalHandler.ProcessRequestAsync(context, item);
110137
}
111138
}
112139

140+
/// <summary>
141+
/// Writes HTML to the output stream in case of GET request using encoding specified in Engine.
142+
/// Writes headers only in caes of HEAD request.
143+
/// </summary>
144+
/// <param name="context">Instace of <see cref="DavContextBaseAsync"/>.</param>
145+
/// <param name="content">String representation of the content to write.</param>
146+
/// <param name="filePath">Relative file path, which holds the content.</param>
147+
private async Task WriteFileContentAsync(DavContextBaseAsync context, string content, string filePath)
148+
{
149+
string contentType = null;
150+
Encoding encoding = context.Engine.ContentEncoding; // UTF-8 by default
151+
context.Response.ContentLength = encoding.GetByteCount(content);
152+
context.Response.ContentType = $"{MimeMapping.GetMimeMapping(filePath)}; charset={encoding.WebName}";
153+
154+
// Return file content in case of GET request, in case of HEAD just return headers.
155+
if (context.Request.HttpMethod == "GET")
156+
{
157+
using (var writer = new StreamWriter(context.Response.OutputStream, encoding))
158+
{
159+
await writer.WriteAsync(content);
160+
}
161+
}
162+
}
163+
113164
/// <summary>
114165
/// This handler shall only be invoked for <see cref="IFolderAsync"/> items or if original handler (which
115166
/// this handler substitutes) shall be called for the item.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="ITHit.WebDAV.Server" version="5.7.3670" targetFramework="net451" />
4-
<package id="ITHit.WebDAV.Server.Web" version="5.7.3670" targetFramework="net451" />
3+
<package id="ITHit.WebDAV.Server" version="6.0.3890-Beta" targetFramework="net451" />
4+
<package id="ITHit.WebDAV.Server.Web" version="6.0.3890-Beta" targetFramework="net451" />
55
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net451" />
66
</packages>

CS/CardDAVServer.FileSystemStorage.AspNet/AjaxFileBrowser/AjaxIntegrationTests.aspx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<!DOCTYPE html>
44
<html lang="en">
55
<head>
6-
<script src="https://www.ajaxbrowser.com/ITHitService/WebDAVAJAXLibrary/Tests/ITHitTests.js" type="text/javascript"></script>
7-
<script src="https://www.ajaxbrowser.com/ITHitService/WebDAVAJAXLibrary/ITHitWebDAVClient.js" type="text/javascript"></script>
6+
<script src="/wwwroot/js/node_modules/webdav.client/Tests/ITHitTests.js" type="text/javascript"></script>
7+
<script src="/wwwroot/js/node_modules/webdav.client/ITHitWebDAVClient.js" type="text/javascript"></script>
88
</head>
99
<body>
1010
</body>

CS/CardDAVServer.FileSystemStorage.AspNet/CardDAVServer.FileSystemStorage.AspNet.csproj

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
77
<ProductVersion>9.0.30729</ProductVersion>
88
<SchemaVersion>2.0</SchemaVersion>
9-
<ProjectGuid>AC412114-493A-4080-A005-BA7861EE24D7</ProjectGuid>
9+
<ProjectGuid>A3F5DECE-C5E3-49A2-BD02-6AC641F0E927</ProjectGuid>
1010
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
1111
<OutputType>Library</OutputType>
1212
<AppDesignerFolder>Properties</AppDesignerFolder>
@@ -120,10 +120,10 @@
120120
</ItemGroup>
121121
<ItemGroup>
122122
<Reference Include="ITHit.WebDAV.Server">
123-
<HintPath>..\packages\ITHit.WebDAV.Server.5.7.3670\lib\net451\ITHit.WebDAV.Server.dll</HintPath>
123+
<HintPath>..\packages\ITHit.WebDAV.Server.6.0.3890-Beta\lib\net451\ITHit.WebDAV.Server.dll</HintPath>
124124
</Reference>
125125
<Reference Include="ITHit.WebDAV.Server.Web">
126-
<HintPath>..\packages\ITHit.WebDAV.Server.Web.5.7.3670\lib\net451\ITHit.WebDAV.Server.Web.dll</HintPath>
126+
<HintPath>..\packages\ITHit.WebDAV.Server.Web.6.0.3890-Beta\lib\net451\ITHit.WebDAV.Server.Web.dll</HintPath>
127127
</Reference>
128128
</ItemGroup>
129129
<PropertyGroup>
@@ -141,7 +141,7 @@
141141
<AutoAssignPort>True</AutoAssignPort>
142142
<DevelopmentServerPort>9658</DevelopmentServerPort>
143143
<DevelopmentServerVPath>/</DevelopmentServerVPath>
144-
<IISUrl>http://localhost:16383/</IISUrl>
144+
<IISUrl>http://localhost:15129/</IISUrl>
145145
<NTLMAuthentication>True</NTLMAuthentication>
146146
<UseCustomServer>False</UseCustomServer>
147147
<CustomServerUrl>
@@ -151,6 +151,15 @@
151151
</FlavorProperties>
152152
</VisualStudio>
153153
</ProjectExtensions>
154+
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
155+
<Exec Command="&quot;$(DevEnvDir)..\..\Web\External\npm.cmd&quot; install webdav.client --prefix wwwroot/js" ContinueOnError="true" StdOutEncoding="utf-8">
156+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
157+
</Exec>
158+
<Exec Command="npm install webdav.client --prefix wwwroot/js" ContinueOnError="true" Condition="'$(ErrorCode)' == '127' OR '$(ErrorCode)' == '3'" StdOutEncoding="utf-8">
159+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
160+
</Exec>
161+
<Error Text="Node.js Package Manager (NPM) is required to download IT Hit WebDAV Ajax Library package. Install NPM from https://npmjs.com and run build again." Condition="'$(ErrorCode)' == '127' OR '$(ErrorCode)' == '9009'" />
162+
</Target>
154163
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
155164
Other similar extension points exist, see Microsoft.Common.targets.
156165
<Target Name="BeforeBuild">

0 commit comments

Comments
 (0)