@@ -79,7 +79,7 @@ public static Task<bool> JsonResponseAsync(
79
79
this IHttpContext context ,
80
80
object data ,
81
81
CancellationToken cancellationToken = default ,
82
- bool useGzip = false )
82
+ bool useGzip = true )
83
83
=> context . JsonResponseAsync ( Json . Serialize ( data ) , cancellationToken , useGzip ) ;
84
84
85
85
/// <summary>
@@ -104,7 +104,7 @@ public static Task<bool> JsonResponseAsync(
104
104
this IHttpContext context ,
105
105
string json ,
106
106
CancellationToken cancellationToken = default ,
107
- bool useGzip = false )
107
+ bool useGzip = true )
108
108
=> context . StringResponseAsync ( json , cancellationToken : cancellationToken , useGzip : useGzip ) ;
109
109
110
110
/// <summary>
@@ -121,7 +121,7 @@ public static Task<bool> HtmlResponseAsync(
121
121
string htmlContent ,
122
122
System . Net . HttpStatusCode statusCode = System . Net . HttpStatusCode . OK ,
123
123
CancellationToken cancellationToken = default ,
124
- bool useGzip = false )
124
+ bool useGzip = true )
125
125
{
126
126
context . Response . StatusCode = ( int ) statusCode ;
127
127
return context . StringResponseAsync ( htmlContent , Responses . HtmlContentType , cancellationToken , useGzip : useGzip ) ;
@@ -156,7 +156,7 @@ public static Task<bool> JsonExceptionResponseAsync(
156
156
this IHttpContext context ,
157
157
Exception ex ,
158
158
System . Net . HttpStatusCode statusCode = System . Net . HttpStatusCode . InternalServerError ,
159
- bool useGzip = false )
159
+ bool useGzip = true )
160
160
{
161
161
context . Response . StatusCode = ( int ) statusCode ;
162
162
return context . JsonResponseAsync ( ex , useGzip : useGzip ) ;
@@ -180,12 +180,9 @@ public static Task<bool> StringResponseAsync(
180
180
string contentType = "application/json" ,
181
181
CancellationToken cancellationToken = default ,
182
182
Encoding encoding = null ,
183
- bool useGzip = false )
183
+ bool useGzip = true )
184
184
{
185
- var bytes = ( encoding ?? Encoding . UTF8 ) . GetBytes ( content ?? string . Empty ) ;
186
-
187
- using ( MemoryStream buffer = new MemoryStream ( bytes ) )
188
- return context . Response . StringResponseAsync ( content , contentType , cancellationToken , encoding , useGzip && context . AcceptGzip ( bytes . Length ) ) ;
185
+ return context . Response . StringResponseAsync ( content , contentType , cancellationToken , encoding , useGzip && context . AcceptGzip ( content . Length ) ) ;
189
186
}
190
187
191
188
/// <summary>
@@ -210,7 +207,7 @@ public static Task<bool> StringResponseAsync(
210
207
{
211
208
response . ContentType = contentType ;
212
209
213
- using ( MemoryStream buffer = new MemoryStream ( ( encoding ?? Encoding . UTF8 ) . GetBytes ( content ) ) )
210
+ using ( var buffer = new MemoryStream ( ( encoding ?? Encoding . UTF8 ) . GetBytes ( content ) ) )
214
211
return BinaryResponseAsync ( response , buffer , cancellationToken , useGzip ) ;
215
212
}
216
213
0 commit comments