/
IResponse.cs
107 lines (92 loc) · 3.92 KB
/
IResponse.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace PuppeteerSharp
{
/// <summary>
/// <see cref="IResponse"/> class represents responses which are received by page.
/// </summary>
/// <seealso cref="IPage.GoForwardAsync(NavigationOptions)"/>
/// <seealso cref="IPage.ReloadAsync(int?, WaitUntilNavigation[])"/>
/// <seealso cref="IPage.Response"/>
/// <seealso cref="IPage.WaitForResponseAsync(Func{IResponse, bool}, WaitForOptions)"/>
public interface IResponse
{
/// <summary>
/// Contains the URL of the response.
/// </summary>
string Url { get; }
/// <summary>
/// An object with HTTP headers associated with the response. All header names are lower-case.
/// </summary>
/// <value>The headers.</value>
Dictionary<string, string> Headers { get; }
/// <summary>
/// Contains the status code of the response.
/// </summary>
/// <value>The status.</value>
HttpStatusCode Status { get; }
/// <summary>
/// Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
/// </summary>
/// <value><c>true</c> if ok; otherwise, <c>false</c>.</value>
bool Ok { get; }
/// <summary>
/// A matching <see cref="Request"/> object.
/// </summary>
/// <value>The request.</value>
IRequest Request { get; }
/// <summary>
/// True if the response was served from either the browser's disk cache or memory cache.
/// </summary>
bool FromCache { get; }
/// <summary>
/// Gets or sets the security details.
/// </summary>
/// <value>The security details.</value>
SecurityDetails SecurityDetails { get; }
/// <summary>
/// Gets a value indicating whether the <see cref="IResponse"/> was served by a service worker.
/// </summary>
/// <value><c>true</c> if the <see cref="IResponse"/> was served by a service worker; otherwise, <c>false</c>.</value>
bool FromServiceWorker { get; }
/// <summary>
/// Contains the status text of the response (e.g. usually an "OK" for a success).
/// </summary>
/// <value>The status text.</value>
string StatusText { get; }
/// <summary>
/// Remove server address.
/// </summary>
RemoteAddress RemoteAddress { get; }
/// <summary>
/// A <see cref="Frame"/> that initiated this request. Or null if navigating to error pages.
/// </summary>
IFrame Frame { get; }
/// <summary>
/// Returns a Task which resolves to a buffer with response body.
/// </summary>
/// <returns>A Task which resolves to a buffer with response body.</returns>
ValueTask<byte[]> BufferAsync();
/// <summary>
/// Returns a Task which resolves to a text representation of response body.
/// </summary>
/// <returns>A Task which resolves to a text representation of response body.</returns>
Task<string> TextAsync();
/// <summary>
/// Returns a Task which resolves to a <see cref="JObject"/> representation of response body.
/// </summary>
/// <seealso cref="JsonAsync{T}"/>
/// <returns>A Task which resolves to a <see cref="JObject"/> representation of response body.</returns>
Task<JObject> JsonAsync();
/// <summary>
/// Returns a Task which resolves to a <typeparamref name="T"/> representation of response body.
/// </summary>
/// <typeparam name="T">The type of the response.</typeparam>
/// <seealso cref="JsonAsync"/>
/// <returns>A Task which resolves to a <typeparamref name="T"/> representation of response body.</returns>
Task<T> JsonAsync<T>();
}
}