-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
44 lines (38 loc) · 1.28 KB
/
Program.cs
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
33
34
35
36
37
38
39
40
41
42
43
44
using ServiceStack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestHttpUtilsFourTwoNine
{
internal class Program
{
static void Main(string[] args)
{
string retryAfterResponseHeader = "Initial Value";
// Change the below to the correct url and port for the service to test against.
// We want the service to return a 429 with a response header Retry-After
string URL = "https://localhost:5001/hello";
try
{
Hello helloRequest = new Hello() { Name = "Elvis" };
URL.PostStringToUrl(helloRequest.ToJson<Hello>(), responseFilter: res =>
{
// this never gets executed if the service called returns a 429 response.
retryAfterResponseHeader = res.GetHeader("Retry-After");
});
}
catch (Exception ex)
{
Console.WriteLine($"Exception encountered: {ex.Message}");
}
Console.WriteLine("Retry-After: " + retryAfterResponseHeader);
Console.ReadKey();
}
}
public class Hello
{
public string Name { get; set; }
}
}