Skip to content

Commit d04ff18

Browse files
Fixes issue in Paging guidance for non-GET requests. Closes #189 (#192)
1 parent 56fa099 commit d04ff18

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

msgraph-developer-proxy-plugins/Guidance/ODataPagingGuidancePlugin.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public override void Register(IPluginEvents pluginEvents,
2929
private void OnBeforeRequest(object? sender, ProxyRequestArgs e)
3030
{
3131
if (_urlsToWatch is null ||
32+
e.Session.HttpClient.Request.Method != "GET" ||
3233
!e.HasRequestUrlMatch(_urlsToWatch))
3334
{
3435
return;
@@ -44,7 +45,11 @@ private void OnBeforeRequest(object? sender, ProxyRequestArgs e)
4445
private async void OnBeforeResponse(object? sender, ProxyResponseArgs e)
4546
{
4647
if (_urlsToWatch is null ||
47-
!e.HasRequestUrlMatch(_urlsToWatch))
48+
e.Session.HttpClient.Request.Method != "GET" ||
49+
!e.HasRequestUrlMatch(_urlsToWatch) ||
50+
e.Session.HttpClient.Response.ContentType is null ||
51+
(!e.Session.HttpClient.Response.ContentType.Contains("json") &&
52+
!e.Session.HttpClient.Response.ContentType.Contains("application/atom+xml")))
4853
{
4954
return;
5055
}
@@ -57,8 +62,11 @@ private async void OnAfterResponse(object? sender, ProxyResponseArgs e)
5762
{
5863
if (_urlsToWatch is null ||
5964
!e.HasRequestUrlMatch(_urlsToWatch) ||
65+
e.Session.HttpClient.Request.Method != "GET" ||
6066
e.Session.HttpClient.Response.StatusCode >= 300 ||
61-
e.Session.HttpClient.Response.ContentType is null)
67+
e.Session.HttpClient.Response.ContentType is null ||
68+
(!e.Session.HttpClient.Response.ContentType.Contains("json") &&
69+
!e.Session.HttpClient.Response.ContentType.Contains("application/atom+xml")))
6270
{
6371
return;
6472
}

0 commit comments

Comments
 (0)