Skip to content

Commit 63e65b0

Browse files
authored
Merge pull request #2687 from gautamdsheth/feature/http2-support
Feature: Added support for HTTP/2 to improve perf
2 parents ef49579 + e4afdda commit 63e65b0

File tree

9 files changed

+14
-3
lines changed

9 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
2323
- Added `-KeyColumn` to `Add-PnPDataRowsToSiteTemplate` which allows for overwriting existing list items in a site template [#2616](https://github.com/pnp/powershell/pull/2616)
2424
- Added `Get-PnPFolderStorageMetric` which allows storage usage of a specific folder to be retrieved [#2646](https://github.com/pnp/powershell/pull/2646)
2525
- Added `IsTeamsConnected`, `IsTeamsChannelConnected` and `TeamChannelType` to be returned when `Get-PnPTenantSite` cmdlet is executed. [#2656](https://github.com/pnp/powershell/pull/2656)
26+
- Added `HTTP/2` support for all HTTP requests to improve performance for HTTP requests. [#2687](https://github.com/pnp/powershell/pull/2687)
2627
- Added `-EnvironmentVariable` parameter to `Connect-PnPOnline` to connect using Azure environment variables. [#2681](https://github.com/pnp/powershell/pull/2681)
2728
- Added `ResponseHeadersVariable` parameter to the `Invoke-PnPSPRestMethod` which if specified will store the response headers values in the PowerShell variable name that is specified. [#2711](https://github.com/pnp/powershell/pull/2711)
2829
- Added `-Filter` parameter to `Get-PnPAzureADServicePrincipal` cmdlet to retrieve specific application registrations based on filter conditions. It supports simple and advanced queries. [#2710](https://github.com/pnp/powershell/pull/2710)

src/Commands/AzureAD/RegisterManagementShellAccess.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ protected override void ProcessRecord()
102102
var httpClient = Framework.Http.PnPHttpClient.Instance.GetHttpClient();
103103
using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, $"https://{GetGraphEndPoint()}/v1.0/organization"))
104104
{
105+
requestMessage.Version = new System.Version(2, 0);
105106
requestMessage.Headers.Add("Authorization", $"Bearer {accessToken}");
106107
requestMessage.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
107108
var response = httpClient.SendAsync(requestMessage).GetAwaiter().GetResult();

src/Commands/Base/InvokeSPRestMethod.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ protected override void ExecuteCmdlet()
8181
{
8282
request.Headers.Add("IF-MATCH", "*");
8383
}
84+
request.Version = new Version(2, 0);
8485

8586
PnPHttpClient.AuthenticateRequestAsync(request, ClientContext).GetAwaiter().GetResult();
8687

src/Commands/Base/TokenHandling.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ internal static async Task<string> GetManagedIdentityTokenAsync(Cmdlet cmdlet, H
148148

149149
using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, tokenRequestUrl))
150150
{
151+
requestMessage.Version = new Version(2, 0);
151152
requestMessage.Headers.Add("Metadata", "true");
152153
if (!string.IsNullOrEmpty(identityHeader))
153154
{

src/Commands/PowerPlatform/PowerAutomate/ExportFlow.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using PnP.PowerShell.Commands.Base;
33
using PnP.PowerShell.Commands.Base.PipeBinds;
44
using PnP.PowerShell.Commands.Utilities.REST;
5+
using System;
56
using System.Management.Automation;
67
using System.Net.Http;
78
using System.Text.Json;
@@ -122,6 +123,7 @@ protected override void ExecuteCmdlet()
122123
var packageLink = valueElement.GetString();
123124
using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, packageLink))
124125
{
126+
requestMessage.Version = new Version(2, 0);
125127
//requestMessage.Headers.Add("Authorization", $"Bearer {AccessToken}");
126128
var response = Connection.HttpClient.SendAsync(requestMessage).GetAwaiter().GetResult();
127129
var byteArray = response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();

src/Commands/Utilities/BrowserHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ internal static bool GetWebBrowserPopup(string siteUrl, string title, (string ur
277277

278278
string requestUrl = string.Format("{0}/_api/contextinfo", siteUrl.TrimEnd('/'));
279279
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUrl);
280+
request.Version = new Version(2, 0);
280281
request.Headers.Add("accept", "application/json;odata=nometadata");
281282
HttpResponseMessage response = await httpClient.SendAsync(request);
282283

src/Commands/Utilities/REST/GraphHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ private static HttpRequestMessage GetMessage(string url, HttpMethod method, PnPC
5555
}
5656

5757
var message = new HttpRequestMessage();
58+
message.Version = new Version(2, 0);
5859
message.Method = method;
5960
message.Headers.TryAddWithoutValidation("Accept", "application/json");
6061
message.RequestUri = !url.StartsWith("https://", StringComparison.OrdinalIgnoreCase) ? new Uri($"https://{connection.GraphEndPoint}/{url}") : new Uri(url);

src/Commands/Utilities/REST/RestHelper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public static async Task<T> PatchAsync<T>(HttpClient httpClient, string url, str
381381

382382
public static async Task<string> PatchAsync(HttpClient httpClient, string url, string accessToken, object payload, string accept = "application/json")
383383
{
384-
HttpRequestMessage message = null;
384+
HttpRequestMessage message = null;
385385
if (payload != null)
386386
{
387387
#if NETFRAMEWORK
@@ -642,6 +642,7 @@ private static HttpRequestMessage GetMessage(string url, HttpMethod method, stri
642642
}
643643

644644
var message = new HttpRequestMessage();
645+
message.Version = new Version(2, 0);
645646
message.Method = method;
646647
message.RequestUri = new Uri(url);
647648
if (!string.IsNullOrEmpty(accessToken))
@@ -665,6 +666,7 @@ private static HttpRequestMessage GetMessage(string url, HttpMethod method, Clie
665666
}
666667

667668
var message = new HttpRequestMessage();
669+
message.Version = new Version(2, 0);
668670
message.Method = method;
669671
message.RequestUri = new Uri(url);
670672
message.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse(accept));

src/Commands/Utilities/VersionChecker.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ internal static string GetAvailableVersion(bool isNightly)
132132

133133
// Deliberately lowering timeout as the version check is not critical so in case of a slower or blocked internet connection, this should not block the cmdlet for too long
134134
httpClient.Timeout = TimeSpan.FromSeconds(VersionCheckTimeOut);
135-
136-
var response = httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, isNightly ? NightlyVersionCheckUrl : ReleaseVersionCheckUrl)).GetAwaiter().GetResult();
135+
var request = new HttpRequestMessage(HttpMethod.Get, isNightly ? NightlyVersionCheckUrl : ReleaseVersionCheckUrl);
136+
request.Version = new Version(2, 0);
137+
var response = httpClient.SendAsync(request).GetAwaiter().GetResult();
137138
if (response.IsSuccessStatusCode)
138139
{
139140
var onlineVersion = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

0 commit comments

Comments
 (0)