Changeset 434 for binary-improvements2/WebServer/src/WebUtils.cs
- Timestamp:
- May 17, 2023, 11:05:59 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/WebUtils.cs
r425 r434 4 4 using System.Net; 5 5 using System.Text; 6 using UnityEngine.Profiling; 6 7 using Utf8Json; 7 8 using Webserver.WebAPI; … … 11 12 namespace Webserver { 12 13 public static class WebUtils { 14 static WebUtils () { 15 JsonWriter writer = new JsonWriter (); 16 writer.WriteBeginArray (); 17 writer.WriteEndArray (); 18 JsonEmptyData = writer.ToUtf8ByteArray (); 19 } 20 13 21 // ReSharper disable once MemberCanBePrivate.Global 14 22 public const string MimePlain = "text/plain"; … … 17 25 public const string MimeJson = "application/json"; 18 26 19 private static readonly UnityEngine.Profiling.CustomSampler envelopeBuildSampler = UnityEngine.Profiling.CustomSampler.Create ("JSON_EnvelopeBuilding");20 private static readonly UnityEngine.Profiling.CustomSampler netWriteSampler = UnityEngine.Profiling.CustomSampler.Create ("JSON_Write");27 private static readonly CustomSampler envelopeBuildSampler = CustomSampler.Create ("JSON_EnvelopeBuilding"); 28 private static readonly CustomSampler netWriteSampler = CustomSampler.Create ("JSON_Write"); 21 29 22 30 public static void WriteText (HttpListenerResponse _resp, string _text, HttpStatusCode _statusCode = HttpStatusCode.OK, string _mimeType = null) { … … 56 64 } 57 65 58 66 public static readonly byte[] JsonEmptyData; 67 59 68 private static readonly byte[] jsonRawDataKey = JsonWriter.GetEncodedPropertyNameWithBeginObject ("data"); // {"data": 60 69 … … 117 126 } 118 127 128 public static void SendEmptyResponse (RequestContext _context, HttpStatusCode _statusCode = HttpStatusCode.OK, byte[] _jsonInputData = null, string _errorCode = null, Exception _exception = null) { 129 PrepareEnvelopedResult (out JsonWriter writer); 130 writer.WriteRaw (JsonEmptyData); 131 SendEnvelopedResult (_context, ref writer, _statusCode, _jsonInputData, _errorCode, _exception); 132 } 133 134 119 135 public static bool TryGetValue (this NameValueCollection _nameValueCollection, string _name, out string _result) { 120 136 _result = _nameValueCollection [_name];
Note:
See TracChangeset
for help on using the changeset viewer.