コード例 #1
0
 public static void WriteEmptyResponse(this HttpMessageWriter writer, StatusCodes statusCode)
 {
     writer.WriteStatusLine(statusCode);
     writer.WriteAccessControlHeaders();
     writer.WriteContentLength(0);
     writer.WriteCRLF();
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
ファイル: AjaxWebsocket.cs プロジェクト: KhaledSMQ/SipServer
        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);
            }
        }
コード例 #5
0
ファイル: AjaxWebsocket.cs プロジェクト: KhaledSMQ/SipServer
        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);
            }
        }