Skip to content

Commit 824d5e7

Browse files
Define a new response type for JSON responses. Make JsonWebResponse public.
1 parent f79d9b6 commit 824d5e7

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

NScrape/JsonWebResponse.cs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
using System;
22
using System.Text;
33

4-
namespace NScrape
5-
{
6-
/// <summary>
7-
/// Represents a web response for a request that returned JSON.
8-
/// </summary>
9-
public class JsonWebResponse : TextWebResponse
10-
{
11-
internal JsonWebResponse(bool success, Uri url, string text, Encoding encoding)
12-
: base(url, WebResponseType.JavaScript, success, text, encoding)
13-
{
14-
}
4+
namespace NScrape {
5+
/// <summary>
6+
/// Represents a web response for a request that returned JSON.
7+
/// </summary>
8+
public class JsonWebResponse : TextWebResponse {
159

16-
/// <summary>
17-
/// Gets the JSON data.
18-
/// </summary>
19-
public string Json { get { return Text; } }
20-
}
10+
/// <summary>
11+
/// Initializes a new instance of the <see cref="JsonWebResponse"/> class.
12+
/// </summary>
13+
/// <param name="success"><b>true</b> if the response is considered successful, <b>false</b> otherwise.</param>
14+
/// <param name="responseUrl">The URL of the response.</param>
15+
/// <param name="text">The JSON text of the response.</param>
16+
/// <param name="encoding">The encoding of the JSON text.</param>
17+
public JsonWebResponse( bool success, Uri responseUrl, string text, Encoding encoding )
18+
: base( responseUrl, WebResponseType.Json, success, text, encoding ) {
19+
}
20+
21+
/// <summary>
22+
/// Gets the JSON data.
23+
/// </summary>
24+
public string Json { get { return Text; } }
25+
}
2126
}

NScrape/TextWebResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public abstract class TextWebResponse : WebResponse {
1717
/// <param name="success"><b>true</b> if the response is considered successful, <b>false</b> otherwise.</param>
1818
/// <param name="text">The text of the response.</param>
1919
/// <param name="encoding">The encoding of the text.</param>
20-
public TextWebResponse( Uri responseUrl, WebResponseType responseType, bool success, string text, Encoding encoding )
20+
protected TextWebResponse( Uri responseUrl, WebResponseType responseType, bool success, string text, Encoding encoding )
2121
: base( responseUrl, responseType, success ) {
2222
this.text = text;
2323
this.encoding = encoding;

NScrape/WebResponseType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public enum WebResponseType {
2323
/// </summary>
2424
JavaScript,
2525

26+
/// <summary>
27+
/// A JSON reponse.
28+
/// </summary>
29+
Json,
30+
2631
/// <summary>
2732
/// A redirect reponse.
2833
/// </summary>

0 commit comments

Comments
 (0)