#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
#if MONO_SECURITY_ALIAS
using MSI = MonoSecurity::Mono.Security.Interface;
#else
using MSI = Mono.Security.Interface;
#endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Threading;
+using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
-using Mono.Net.Security;
namespace System.Net {
sealed class HttpConnection
int reuses;
bool context_bound;
bool secure;
- X509Certificate2 cert;
+ X509Certificate cert;
int s_timeout = 90000; // 90k ms for first request, 15k ms from then on
Timer timer;
IPEndPoint local_ep;
HttpListener last_listener;
int [] client_cert_errors;
X509Certificate2 client_cert;
- IMonoSslStream ssl_stream;
+ SslStream ssl_stream;
- public HttpConnection (Socket sock, EndPointListener epl, bool secure, X509Certificate2 cert)
+ public HttpConnection (Socket sock, EndPointListener epl, bool secure, X509Certificate cert)
{
this.sock = sock;
this.epl = epl;
client_cert_errors = new int[] { (int)e };
return true;
});
- stream = ssl_stream.AuthenticatedStream;
+ stream = ssl_stream;
}
timer = new Timer (OnTimeout, null, Timeout.Infinite, Timeout.Infinite);
Init ();
}
+ internal SslStream SslStream {
+ get { return ssl_stream; }
+ }
+
internal int [] ClientCertificateErrors {
get { return client_cert_errors; }
}
// TODO: can we get this stream before reading the input?
if (o_stream == null) {
HttpListener listener = context.Listener;
- bool ign = (listener == null) ? true : listener.IgnoreWriteExceptions;
- o_stream = new ResponseStream (stream, context.Response, ign);
+
+ if(listener == null)
+ return new ResponseStream (stream, context.Response, true);
+
+ o_stream = new ResponseStream (stream, context.Response, listener.IgnoreWriteExceptions);
}
return o_stream;
}
int used = 0;
string line;
- try {
- line = ReadLine (buffer, position, len - position, ref used);
- position += used;
- } catch {
- context.ErrorMessage = "Bad request";
- context.ErrorStatus = 400;
- return true;
- }
+ while (true) {
+ if (context.HaveError)
+ return true;
+
+ if (position >= len)
+ break;
+
+ try {
+ line = ReadLine (buffer, position, len - position, ref used);
+ position += used;
+ } catch {
+ context.ErrorMessage = "Bad request";
+ context.ErrorStatus = 400;
+ return true;
+ }
- do {
if (line == null)
break;
+
if (line == "") {
if (input_state == InputState.RequestLine)
continue;
return true;
}
}
-
- if (context.HaveError)
- return true;
-
- if (position >= len)
- break;
- try {
- line = ReadLine (buffer, position, len - position, ref used);
- position += used;
- } catch {
- context.ErrorMessage = "Bad request";
- context.ErrorStatus = 400;
- return true;
- }
- } while (line != null);
+ }
if (used == len) {
ms.SetLength (0);
HttpListenerResponse response = context.Response;
response.StatusCode = status;
response.ContentType = "text/html";
- string description = HttpListenerResponse.GetStatusDescription (status);
+ string description = HttpListenerResponseHelper.GetStatusDescription (status);
string str;
if (msg != null)
str = String.Format ("<h1>{0} ({1})</h1>", description, msg);