-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFlightPolicy.cs
More file actions
32 lines (30 loc) · 1002 Bytes
/
FlightPolicy.cs
File metadata and controls
32 lines (30 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Azure.Core;
using Azure.Core.Pipeline;
namespace DocumentTranslationService
{
internal class FlightPolicy : HttpPipelineSynchronousPolicy
{
private readonly string[] flightStrings;
/// <summary>
/// Sets the string to be used in a flight
/// </summary>
/// <param name="flightString">the string to be used in a flight</param>
public FlightPolicy(string flightString)
{
char[] splitchars = { ',', ';', ' ' };
this.flightStrings = flightString.Split(splitchars);
}
public override void OnSendingRequest(HttpMessage message)
{
if (message.Request.Method.Method == "POST")
{
foreach (string s in flightStrings)
{
string st = s.Trim();
if (!string.IsNullOrEmpty(st))
message.Request.Uri.AppendQuery("flight", st);
}
}
}
}
}