Skip to content

Commit 8fb11a7

Browse files
Update master from dev since we've published. (#300)
* expose HttpProvider internal constructor with param HttpMessageHandle… (#289) * expose HttpProvider internal constructor with param HttpMessageHandler to public * Update HttpProviderTests.cs * add unit tests * Add Dispose method to RedirectHander and Xunit tests for RedirectHandler * 1. Update RedirectHandler SendAsync method 2. Add RedriectHandlerTests for RedirectHandler in Microsoft.Graph.Core.Test with Mstest framework 3. Update RedirecthHandlerTests for RedirecthHandler in Microsoft.Graph.DotnetCore.Core.Test to test excpetioons thrown. * 1. Update CopyRequest Method for setting content 1. Update IsRedirect Method to be more explicit 3. Update SendAsync for re-issue request and removeAuth 4. Add tests for updates * 1. change Dispose Method and typo in comments 2. remove ref * remove ref * remove NuGetPackageImportStamp * disable PlannerTests * move copy content into CopyRequest Method * remove unnessary dispose and fix typo * remove unused comments and fix tests issues. * Generated new files that support the Security API, updates to the Intune API, Insights functionality on the user, MailTips, update to the subscription entity and additional documentation comments that will be used in the IntelliSense file. (#298) * Updated copyright, version, and release notes. (#299) * updated copyright per requirements * Updated spec for build and packaging.
1 parent 044880e commit 8fb11a7

File tree

270 files changed

+13549
-449
lines changed

Some content is hidden

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

270 files changed

+13549
-449
lines changed

Microsoft.Graph.sln

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,7 @@ Global
135135
{9F04608C-D845-4445-83B1-E6D4EEE38CBC} = {5E0B65FC-67B7-41F8-87BF-96D6A342C438}
136136
{5169EDAD-1E05-42A5-A241-D6FA78A02C5C} = {6496B661-8321-4D07-ACC2-B6602649293C}
137137
EndGlobalSection
138+
GlobalSection(ExtensibilityGlobals) = postSolution
139+
SolutionGuid = {0DB06E6E-58F0-497F-9ECC-00DD03BA9357}
140+
EndGlobalSection
138141
EndGlobal

src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Description>Microsoft Graph Core Client Library implements core functionality used by Microsoft Graph Client Libraries.</Description>
4-
<Copyright>Copyright (c) Microsoft Corporation</Copyright>
4+
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
55
<AssemblyTitle>Microsoft Graph Core Client Library</AssemblyTitle>
6-
<VersionPrefix>1.10.0</VersionPrefix>
7-
<FileVersion>1.10.0</FileVersion>
8-
<AssemblyVersion>1.10.0</AssemblyVersion>
6+
<VersionPrefix>1.11.0</VersionPrefix>
7+
<FileVersion>1.11.0</FileVersion>
8+
<AssemblyVersion>1.11.0</AssemblyVersion>
99
<Authors>Microsoft</Authors>
1010
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>
1111
<PreserveCompilationContext>false</PreserveCompilationContext>
1212
<AssemblyName>Microsoft.Graph.Core</AssemblyName>
1313
<PackageId>Microsoft.Graph.Core</PackageId>
1414
<PackageTags>Microsoft Office365;Graph;GraphServiceClient;Outlook;OneDrive;AzureAD;GraphAPI;Productivity;SharePoint;Intune;SDK</PackageTags>
1515
<PackageReleaseNotes>
16-
July 2018 Release Summary (version 1.10.0)
16+
September 2018 Release Summary (version 1.11.0)
1717

18-
New features
19-
- Added the ability to append an arbitrary URL segment to a request. This will support the creation of custom requests.
20-
- Set signing properties in .csproj to be 'false' by default.
18+
- exposed the HttpProvider constructor
2119
</PackageReleaseNotes>
2220
<PackageProjectUrl>https://developer.microsoft.com/graph</PackageProjectUrl>
2321
<PackageLicenseUrl>http://aka.ms/devservicesagreement</PackageLicenseUrl>
@@ -37,7 +35,7 @@ New features
3735
<DelaySign>false</DelaySign>
3836
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
3937
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
40-
<Version>1.10.0</Version>
38+
<Version>1.11.0</Version>
4139
</PropertyGroup>
4240
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard1.1|AnyCPU'">
4341
<DocumentationFile>bin\Release\netstandard1.1\Microsoft.Graph.Core.xml</DocumentationFile>
@@ -61,4 +59,7 @@ New features
6159
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' ">
6260
<PackageReference Include="Newtonsoft.Json" Version="[9.0.1,12)" />
6361
</ItemGroup>
62+
<ItemGroup>
63+
<PackageReference Include="System.Net.Http" Version="4.3.3" />
64+
</ItemGroup>
6465
</Project>

src/Microsoft.Graph.Core/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
//
2525
// You can specify all the values or you can default the Build and Revision Numbers
2626
// by using the '*' as shown below:
27-
[assembly: AssemblyVersion("1.10.0")]
28-
[assembly: AssemblyFileVersion("1.10.0.0")]
27+
[assembly: AssemblyVersion("1.11.0")]
28+
[assembly: AssemblyFileVersion("1.11.0.0")]
2929

3030
#if DEBUG
3131
[assembly: InternalsVisibleTo("Microsoft.Graph.Core.Test")]

src/Microsoft.Graph.Core/Requests/HttpProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public HttpProvider(HttpClientHandler httpClientHandler, bool disposeHandler, IS
5757
/// <param name="httpMessageHandler">An HTTP message handler to pass to the <see cref="HttpClient"/> for sending requests.</param>
5858
/// <param name="disposeHandler">Whether or not to dispose the client handler on Dispose().</param>
5959
/// <param name="serializer">A serializer for serializing and deserializing JSON objects.</param>
60-
internal HttpProvider(HttpMessageHandler httpMessageHandler, bool disposeHandler, ISerializer serializer)
60+
public HttpProvider(HttpMessageHandler httpMessageHandler, bool disposeHandler, ISerializer serializer)
6161
{
6262
this.disposeHandler = disposeHandler;
6363
this.httpMessageHandler = httpMessageHandler ?? new HttpClientHandler { AllowAutoRedirect = false };
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
namespace Microsoft.Graph
6+
{
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Net.Http;
10+
using System.Text;
11+
using System.Net.Http.Headers;
12+
using System.Threading;
13+
using System.Threading.Tasks;
14+
using System.Net;
15+
using System.IO;
16+
17+
/// <summary>
18+
/// An <see cref="DelegatingHandler"/> implementation using standard .NET libraries.
19+
/// </summary>
20+
public class RedirectHandler : DelegatingHandler
21+
{
22+
23+
private const int maxRedirects = 5;
24+
25+
/// <summary>
26+
/// Constructs a new <see cref="RedirectHandler"/>
27+
/// </summary>
28+
/// <param name="innerHandler">An HTTP message handler to pass to the <see cref="HttpMessageHandler"/> for sending requests.</param>
29+
public RedirectHandler(HttpMessageHandler innerHandler)
30+
{
31+
InnerHandler = innerHandler;
32+
}
33+
34+
35+
/// <summary>
36+
/// Sends the Request
37+
/// </summary>
38+
/// <param name="request">The <see cref="HttpRequestMessage"/> to send.</param>
39+
/// <param name="cancellationToken">The <see cref="CancellationToken"/>for the request.</param>
40+
/// <returns>The <see cref="HttpResponseMessage"/>.</returns>
41+
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
42+
{
43+
44+
// send request first time to get response
45+
var response = await base.SendAsync(request, cancellationToken);
46+
47+
// check response status code
48+
if (IsRedirect(response.StatusCode))
49+
{
50+
51+
var redirectCount = 0;
52+
53+
while (redirectCount < maxRedirects)
54+
{
55+
// general copy request with internal CopyRequest(see copyRequest for details) method
56+
var newRequest = await CopyRequest(response.RequestMessage);
57+
58+
// status code == 303: change request method from post to get and content to be null
59+
if (response.StatusCode == HttpStatusCode.SeeOther)
60+
{
61+
newRequest.Content = null;
62+
newRequest.Method = HttpMethod.Get;
63+
}
64+
65+
// Set newRequestUri from response
66+
newRequest.RequestUri = response.Headers.Location;
67+
68+
// Remove Auth if http request's scheme or host changes
69+
if (String.Compare(newRequest.RequestUri.Host, request.RequestUri.Host, StringComparison.OrdinalIgnoreCase) != 0 ||
70+
!newRequest.RequestUri.Scheme.Equals(request.RequestUri.Scheme))
71+
{
72+
newRequest.Headers.Authorization = null;
73+
}
74+
75+
// Send redirect request to get reponse
76+
response = await base.SendAsync(newRequest, cancellationToken);
77+
78+
// Check response status code
79+
if (!IsRedirect(response.StatusCode))
80+
{
81+
return response;
82+
}
83+
redirectCount++;
84+
}
85+
throw new ServiceException(
86+
new Error
87+
{
88+
Code = ErrorConstants.Codes.TooManyRedirects,
89+
Message = string.Format(ErrorConstants.Messages.TooManyRedirectsFormatString, redirectCount)
90+
});
91+
92+
}
93+
return response;
94+
95+
}
96+
97+
/// <summary>
98+
/// Create a new HTTP request by copying previous HTTP request's headers and properties from response's request message.
99+
/// </summary>
100+
/// <param name="originalRequest">The previous <see cref="HttpRequestMessage"/> needs to be copy.</param>
101+
/// <returns>The <see cref="HttpRequestMessage"/>.</returns>
102+
/// <remarks>
103+
/// Re-issue a new HTTP request with the previous request's headers and properities
104+
/// </remarks>
105+
internal async Task<HttpRequestMessage> CopyRequest(HttpRequestMessage originalRequest)
106+
{
107+
var newRequest = new HttpRequestMessage(originalRequest.Method, originalRequest.RequestUri);
108+
109+
foreach (var header in originalRequest.Headers)
110+
{
111+
newRequest.Headers.TryAddWithoutValidation(header.Key, header.Value);
112+
}
113+
114+
foreach (var property in originalRequest.Properties)
115+
{
116+
newRequest.Properties.Add(property);
117+
}
118+
119+
// Set Content if previous request contains
120+
if (originalRequest.Content != null && originalRequest.Content.Headers.ContentLength != 0)
121+
{
122+
newRequest.Content = new StreamContent(await originalRequest.Content.ReadAsStreamAsync());
123+
}
124+
125+
return newRequest;
126+
}
127+
128+
129+
/// <summary>
130+
/// Checks whether <see cref="HttpStatusCode"/> is redirected
131+
/// </summary>
132+
/// <param name="statusCode">The <see cref="HttpStatusCode"/>.</param>
133+
/// <returns>Bool value for redirection or not</returns>
134+
private bool IsRedirect(HttpStatusCode statusCode)
135+
{
136+
if (statusCode == HttpStatusCode.MovedPermanently ||
137+
statusCode == HttpStatusCode.Found ||
138+
statusCode == HttpStatusCode.SeeOther ||
139+
statusCode == HttpStatusCode.TemporaryRedirect ||
140+
statusCode == (HttpStatusCode)308
141+
)
142+
{
143+
return true;
144+
}
145+
return false;
146+
}
147+
148+
149+
}
150+
151+
}

src/Microsoft.Graph/Microsoft.Graph.csproj

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Description>Microsoft Graph Client Library allows you to call Office 365, Azure AD and other Microsoft services through a single unified developer experience.</Description>
4-
<Copyright>Copyright (c) Microsoft Corporation</Copyright>
4+
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
55
<AssemblyTitle>Microsoft Graph Client Library</AssemblyTitle>
6-
<VersionPrefix>1.10.0</VersionPrefix>
7-
<FileVersion>1.10.0</FileVersion>
8-
<AssemblyVersion>1.10.0</AssemblyVersion>
6+
<VersionPrefix>1.11.0</VersionPrefix>
7+
<FileVersion>1.11.0</FileVersion>
8+
<AssemblyVersion>1.11.0</AssemblyVersion>
99
<Authors>Microsoft</Authors>
1010
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>
1111
<PreserveCompilationContext>false</PreserveCompilationContext>
1212
<AssemblyName>Microsoft.Graph</AssemblyName>
1313
<PackageId>Microsoft.Graph</PackageId>
1414
<PackageTags>Microsoft Office365;Graph;GraphServiceClient;Outlook;OneDrive;AzureAD;GraphAPI;Productivity;SharePoint;Intune;SDK</PackageTags>
1515
<PackageReleaseNotes>
16-
July 2018 Release Summary (version 1.10.0)
16+
September 2018 Release Summary (version 1.11.0)
1717

18-
- Updated reference to System.Net.Http to address a vulnerability and issue with .Net &gt;=4.7.2.
19-
- Set signing properties in .csproj to be 'false' by default.
20-
- Added custom request builders that help add user activity and history.
18+
- Support the new Security Alerts API
19+
- Updates to the Intune API
20+
- Insights functionality updated for the user entity
21+
- MailTips are now enabled
22+
- Update to the subscription entity and additional documentation comments propagated to the IntelliSense file.
23+
- EducationClass entities now support adding reference navigation to the teachers and members entity collections.
2124
</PackageReleaseNotes>
2225
<PackageProjectUrl>https://developer.microsoft.com/graph</PackageProjectUrl>
2326
<PackageLicenseUrl>http://aka.ms/devservicesagreement</PackageLicenseUrl>
@@ -37,7 +40,7 @@ July 2018 Release Summary (version 1.10.0)
3740
<DelaySign>false</DelaySign>
3841
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
3942
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
40-
<Version>1.10.0</Version>
43+
<Version>1.11.0</Version>
4144
</PropertyGroup>
4245
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard1.1|AnyCPU'">
4346
<DocumentationFile>bin\Release\Microsoft.Graph.xml</DocumentationFile>

0 commit comments

Comments
 (0)