public static void WriteEmptyResponse(this HttpMessageWriter writer, StatusCodes statusCode) { writer.WriteStatusLine(statusCode); writer.WriteAccessControlHeaders(); writer.WriteContentLength(0); writer.WriteCRLF(); }
public static void WriteResponse(this HttpMessageWriter writer, StatusCodes statusCodes, ContentType contentType, byte[] content) { writer.WriteStatusLine(statusCodes); writer.WriteAccessControlHeaders(); writer.WriteContentType(contentType); writer.WriteContentLength(content.Length); writer.WriteCRLF(); writer.Write(content); }
public static void WriteNotFinishedResponse(this HttpMessageWriter writer, StatusCodes statusCode, ContentType contentType) { writer.WriteStatusLine(statusCode); writer.WriteAccessControlHeaders(); if (contentType != ContentType.None) { writer.WriteContentType(contentType); } else { writer.WriteContentLength(0); } }
private static void WriteHttpHeader(ServerAsyncEventArgs e) { using (var writer = new HttpMessageWriter()) { writer.WriteStatusLine(StatusCodes.OK); writer.WriteContentLength(e.Count); writer.WriteAccessControlHeaders(); writer.WriteCRLF(); e.OffsetOffset -= writer.Count; e.Count += writer.Count; Buffer.BlockCopy(writer.Buffer, writer.Offset, e.Buffer, e.Offset, writer.Count); } }
private void SendJsonMessage(Session session) { using (var writer = new HttpMessageWriter()) { //byte[] json = Encoding.UTF8.GetBytes(string.Format(@"{{id:{0}}}", session.Id)); byte[] json = Encoding.UTF8.GetBytes(string.Format(@"{0}", session.Id)); writer.WriteStatusLine(StatusCodes.OK); //writer.Write(Encoding.UTF8.GetBytes("Content-Type: application/json\r\n")); writer.WriteContentLength(json.Length); writer.WriteAccessControlHeaders(); writer.WriteCRLF(); writer.Write(json); SendWriter(session, writer); } }