Skip to content

Commit 4350a82

Browse files
committed
fix: plaintext strings
1 parent b2860b9 commit 4350a82

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

frameworks/CSharp/sisk/sisk-cadente/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ void Host_ContextCreated ( HttpHost sender, HttpHostContext session ) {
2525

2626
static void SerializePlainTextResponse ( HttpHostContext.HttpResponse response ) {
2727

28-
var messageBytes = Encoding.UTF8.GetBytes ( "Hello, world!" );
28+
var messageBytes = Encoding.UTF8.GetBytes ( "Hello, World!" );
2929

30-
response.Headers.Add ( new HttpHeader ( "Content-Type", "text/plain" ) );
30+
response.Headers.Add ( new HttpHeader ( "Content-Type", "text/plain; charset=UTF-8" ) );
3131
response.ResponseStream = new MemoryStream ( messageBytes );
3232
}
3333

3434
static void SerializeJsonResponse ( HttpHostContext.HttpResponse response ) {
3535

3636
var contentBytes = JsonSerializer.SerializeToUtf8Bytes ( new {
37-
message = "Hello, world!"
37+
message = "Hello, World!"
3838
} );
3939

4040
response.Headers.Add ( new HttpHeader ( "Content-Type", "application/json" ) );
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
using System.Net.Http.Json;
2+
using System.Text;
23
using Sisk.Core.Http;
34
using Sisk.Core.Routing;
45

56
var app = HttpServer.CreateBuilder ( host => {
67
host.UseListeningPort ( "http://+:8080/" );
8+
host.UseConfiguration ( config => {
9+
config.AccessLogsStream = null;
10+
} );
711
} ).Build ();
812

913
app.Router.SetRoute ( RouteMethod.Get, "/plaintext", PlainText );
@@ -12,11 +16,11 @@
1216
app.Start ();
1317

1418
static HttpResponse PlainText ( HttpRequest request ) {
15-
return new HttpResponse ( "Hello, world!" );
19+
return new HttpResponse ( new StringContent ( "Hello, World!", Encoding.UTF8, "text/plain" ) );
1620
}
1721

1822
static HttpResponse Json ( HttpRequest request ) {
1923
return new HttpResponse ( JsonContent.Create ( new {
20-
message = "Hello, world!"
24+
message = "Hello, World!"
2125
} ) );
2226
}

0 commit comments

Comments
 (0)