websocket-server – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.Diagnostics; |
||
4 | using System.Linq; |
||
5 | using System.Text; |
||
6 | using System.Net.Sockets; |
||
7 | using WebSockets.Common; |
||
8 | using System.IO; |
||
9 | |||
10 | namespace WebSockets.Server.Http |
||
11 | { |
||
12 | public class BadRequestService : IService |
||
13 | { |
||
14 | private readonly Stream _stream; |
||
15 | private readonly string _header; |
||
16 | private readonly IWebSocketLogger _logger; |
||
17 | |||
18 | public BadRequestService(Stream stream, string header, IWebSocketLogger logger) |
||
19 | { |
||
20 | _stream = stream; |
||
21 | _header = header; |
||
22 | _logger = logger; |
||
23 | } |
||
24 | |||
25 | public void Respond() |
||
26 | { |
||
27 | HttpHelper.WriteHttpHeader("HTTP/1.1 400 Bad Request", _stream); |
||
28 | |||
29 | // limit what we log. Headers can be up to 16K in size |
||
30 | string header = _header.Length > 255 ? _header.Substring(0,255) + "..." : _header; |
||
31 | _logger.Warning(this.GetType(), "Bad request: '{0}'", header); |
||
32 | } |
||
33 | |||
34 | public void Dispose() |
||
35 | { |
||
36 | // do nothing |
||
37 | } |
||
38 | } |
||
39 | } |