54 Commits
Author SHA1 Message Date
Martin Baulig 5c0f506a8d [System]: Replace HttpListenerResponseHelper with HttpStatusDescription from CoreFX (#4833)
* [System]: Replace HttpListenerResponseHelper with HttpStatusDescription from CoreFX.

* Update common.sources
2017-05-12 14:32:50 -04:00
Martin Baulig 280f222afa [System]: Remove 'SECURITY_DEP' conditional from HttpListener and related classes. (#4810) 2017-05-09 11:22:19 -04:00
Martin Baulig 69689c95e5 [System]: Make HttpListener partial and move Mono-specific bits into HttpListener.Mono.cs. (#4808)
* [System]: Make HttpListener partial and move Mono-specific bits into HttpListener.Mono.cs.

* Remove ancient EMBEDDED_IN_1_0 conditional.

* Remove unused using statements.

* HttpListener.CreateSslStream() now uses RemoteCertificateValidationCallback.
2017-05-08 16:27:04 -04:00
Martin Baulig 5e08742b5c [System]: Fix bug #52508 in HttpListener when doing multiple Https request.
Move the call to SslStream.AuthenticateAsServer() into the constructor because
we don't want to call it again when Init() is called from Close().
2017-04-26 18:54:27 -04:00
Martin Baulig cb885fe3e0 [Mono.Security.Interface]: Improve synergy between SslStream and IMonoSslStream (#4756)
* [Mono.Security.Interface]: Improve synergy between `MonoTlsProvider`, `SslStream` and `IMonoSslStream`.

* Add `IMonoSslStream.SslStream` property; the `IMonoSslStream` is now only created my the `SslStream`
  constructor, so `SslStream` "owns" the `IMonoSslStream`.

* Add internal `MonoTlsProvider.CreateSslStreamInternal()`.

* `SslStream` does not need to implement any additional interfaces; we can do without after
   getting rid of the wrapper classes.

* Add internal `SslStream.CreateMonoSslStream(Stream,bool,MonoTlsProvider,MonoTlsSettings)`.

* `MonoTlsProvider.CreateSslStream()` implementations should use this new method.

* Remove ancient obsolete MonoTlsProviderFactory APIs.

* `HttpListener` and `HttpConnection` now use `SslStream` instead of `IMonoSslStream`.

* [System]: Cleanup internal TLS Provider registration.

* Make it build.
2017-04-26 17:15:37 -04:00
Martin Baulig 00ef68347f [Mono.Security.Interface]: Add MonoTlsProviderFactory.GetMonoSslStream(HttpListenerContext). (#4749)
* [System]: Cleanup 'SECURITY_DEP' conditionals in the internal TLS code.

* [System]: Remove 'Mono.Net.Security.IMonoSslStream'; use 'Mono.Security.Interface.IMonoSslStream' instead.

* [System]: Remove 'Mono.Net.Security.IMonoTlsProvider'; use 'Mono.Security.Interface.MonoTlsProvider' instead.

* [System]: Cleanup internal TLS code.

* [Mono.Security]: Add MonoTlsProviderFactory.GetSslStream(HttpListenerContext).

* [System]: `SslStream' should not implement any additional interfaces.
2017-04-26 10:29:36 -04:00
Marek Safar aa77a6ddcc [System] Remove PrebuiltSystem alias (it's not needed with any modern mcs) 2016-04-16 08:37:07 +02:00
Sebastien Pouliot 789f4b7651 [System] Move HttpListenerResponse.GetStatusDescription to ease linking
The use of HttpResponseMessage.ReasonPhrase means:

* marking the HttpListenerResponse.GetStatusDescription method;
* marking the HttpListenerResponse type;
* which implements IDisposable, so it's Dispose method is marked
* marking the Close method...

from there a metric ton of code gets recursively marked to the point
where the whole SSL/TLS server code gets inside the app.

To avoid this we move the GetStatusDescription to a different
type that won't bring the end of the civilized world so fast.
2016-01-27 22:12:13 -05:00
bogdanov 10e5aba155 [HttpConnection] Bug fix: HttpListener's "IgnoreWriteExceptions" property value is ignored when "Expect: 100-Continue" header set in request
The problem is connected with "Listener" property of "context" object. It is null in "GetResponseStream" method, when it's called internally from "FinishInitialization" method of "HttpListenerRequest" class. This problem is possible only in situation when we have "Expect: 100-Continue" header from http client.

This change is released under the MIT license.
2015-12-13 18:29:12 +05:00
Martin Baulig 0d585d53ee [Mono.Security]: Make MonoTlsProviderFactory.CreateHttpListener() take 'X509Certificate' instead of 'X509Certificate2'.
(cherry picked from commit 3d81daf796)
2015-11-10 15:31:21 -05:00
Martin Baulig 65ccd579eb Merge pull request #2102 from AdamBurgess/master
[System] Fix bug #31209 - HttpConnection infinite loop
2015-11-06 15:49:10 -05:00
Martin Baulig 3fda636ef7 [Mono.Security]: Add new MonoTlsProviderFactory.CreateHttpListener() API to create a HttpListener.
This new method lets you create a 'HttpListener' and specify the X509Certificate2 to use
(so you don't have to put it into ~/.config/.mono/httplistener) as well as an optional
'MonoTlsProvider' and optional 'MonoTlsSettings'.
2015-10-29 15:55:36 -04:00
Martin Baulig 0e956c0902 [System]: Use the new 'MonoTlsProvider' framework in 'HttpListener'.
This makes 'HttpListener' use 'SslStream', which can now switch the
TLS implementation at runtime.
2015-10-29 15:52:31 -04:00
Martin Baulig 35411c095d Remove a few more 'using System.Reflection's. 2015-10-23 16:05:19 -04:00
Adam Burgess 101bd2a868 [System] Fix bug #31209 - HttpConnection infinite loop
A continue statement in a do...while loop was skipping code to read the next line in a connection, causing an infinite loop.
Fixed by refactoring the loop, removing duplicated code.
2015-10-02 14:11:11 +00:00
Marek Safar a6dccdaf6d Revert "Merge pull request #981 from methane/websocket"
This reverts commit 62cc262196, reversing
changes made to c1028cf912.
2014-05-23 17:24:45 +02:00
Marek Safar 62cc262196 Merge pull request #981 from methane/websocket
[websocket] Implement HttpListenerContext.AcceptWebSocketAsync()
2014-05-20 19:56:13 +02:00
Marek Habersack 34fb07d05f Include support for SSL/TLS right in System when building for the MONODROID profile
This patch builds upon commit 96a8500795 which placed parts of Mono.Security
responsible for dealing with SSL/TLS certificates for the purpose of certificate verification. The code enables
validation of the certifcates even if the user does not provide their own validation callback. The changes as related to
the original commit are few, basically consisting of enabling the same code used by MonoTouch in the MonoDroid context with
the only actual code change being the certificate validation bit mentioned above.

Since the change involves adding a subset of Mono.Security files to the monodroid version of System.dll, it is
also necessary to remove Mono.Android's dependence on Mono.Security.dll. The reason is that the code in AndroidPlatform
which looks up TLS support methods in Mono.Android.dll would use a type (X509CertificateCollection) that is now part of
System.dll but is *also* in Mono.Security.dll referenced by Mono.Android.dll and therefore the lookup would fail since
we'd have two distinct types from the reflection point of view.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=18962
2014-04-25 21:39:53 +02:00
INADA Naoki 298e70c307 Fix some bugs. 2014-04-12 02:49:08 +09:00
INADA Naoki 4239b4cb2e Reimplement StreamWebSocket. 2014-04-11 23:15:24 +09:00
INADA Naoki 69b3e44b11 [websocket] Better hijacking. 2014-04-07 11:08:18 +09:00
INADA Naoki 7e221721de [websocket] Implement HttpListenerContext.AcceptWebSocketAsync(). 2014-04-07 10:36:03 +09:00
Sebastien Pouliot 96a8500795 Allow the MONOTOUCH targetr to build its SSL/TLS support right inside System.dll and remove code duplication and non-required code paths. 2013-07-01 16:21:04 -04:00
Marek Safar 0647a5d16b Remove duplicated files from system.dll (saves about 100kb) 2013-02-25 19:10:09 +01:00
Marek Safar eb4e581e88 Few few httplistener races 2012-06-15 13:50:23 +01:00
Gonzalo Paniagua Javier 05f25eaaaa Add support for client certificates to HttpListener
Fixes bug #3969.
2012-04-30 17:31:01 -04:00
Gonzalo Paniagua Javier 0b019a73d4 [HttpListener] Fix keep-alive connections
We were removing the connection in the wrong place.
	Also unbind the context in other error situations like a read failure
	after the headers are in.
2011-03-22 11:21:28 -04:00
Gonzalo Paniagua Javier 79a054063a [HttpListener] Avoid contention
-Lock-free reads from registered listeners.
	-Don't register the context until *all* the setup steps are done.
2011-03-14 17:59:51 -04:00
Gonzalo Paniagua Javier d420dafa92 [HttpListener] Plug leak. 2011-03-11 01:46:04 -05:00
Gonzalo Paniagua Javier 87ee560127 [HttpListener] Memory use reductions 2011-03-10 00:44:56 -05:00
Gonzalo Paniagua Javier eae45fd704 [HttpListener] Close idle connections on Stop()
Idle connections that never received any data or had ever been
	associated to a listener are properly closed now when the endpoint is
	closed or the last listener they used is closed.
	Fixes a bunch of tests in System.ServiceModel.
2011-02-15 01:52:50 -05:00
Gonzalo Paniagua Javier b061ae7569 [HttpListener] Small improvements
Less allocations in managed and unmanaged code.
2011-02-13 08:18:57 -05:00
Gonzalo Paniagua Javier e71a9ba492 Avoid killing the thread if socket already null
In some weird cases socket is null when we try to close it.
2010-11-01 18:54:14 -04:00
Gonzalo Paniagua Javier d20e427694 Add connection timers and reuses
Use a timer to handle read timeouts and extend reuses to regular
	connections, not just chunked. The timer is set to 90s for the first
	request and 15s for subsequent requests.
2010-10-25 20:27:48 -04:00
Marek Safar aad016fd87 Clean up few more warnings 2010-10-15 15:20:25 +01:00
Miguel de Icaza f47e5fe6a6 2010-03-20 Miguel de Icaza <[email protected]>
* Eliminate warnings in a bunch of places.

svn path=/trunk/mcs/; revision=153952
2010-03-20 23:09:06 +00:00
Miguel de Icaza 11ca00c93b 2010-03-19 Miguel de Icaza <[email protected]>
* Eliminate warnings in a bunch of places.

svn path=/trunk/mcs/; revision=153923
2010-03-19 21:46:30 +00:00
Gonzalo Paniagua Javier 8df3b9fd32 2010-03-09 Gonzalo Paniagua Javier <[email protected]>
* HttpConnection.cs: set the right position when a CR is found.
	Fixes bug #577891.


svn path=/trunk/mcs/; revision=153309
2010-03-09 07:45:32 +00:00
Gonzalo Paniagua Javier cddd78ded6 2010-03-09 Gonzalo Paniagua Javier <[email protected]>
* HttpListener.cs:
	* HttpListenerRequest.cs:
	* ListenerAsyncResult.cs:
	* HttpConnection.cs: make sure there is no pending input when reusing
	the connection.


svn path=/trunk/mcs/; revision=153300
2010-03-09 06:05:10 +00:00
Gonzalo Paniagua Javier f512a21cb8 2009-09-15 Gonzalo Paniagua Javier <[email protected]>
* HttpListenerRequest.cs: add the right status code.
	* HttpConnection.cs: exception might come from more places when
	reading the input. Catch all of them.


svn path=/trunk/mcs/; revision=142004
2009-09-16 01:27:36 +00:00
Gonzalo Paniagua Javier b0ea001694 2009-06-26 Gonzalo Paniagua Javier <[email protected]>
* HttpConnection.cs:
	* HttpListenerResponse.cs: force closing the socket when the response
	is aborted.


svn path=/trunk/mcs/; revision=137016
2009-06-26 22:37:38 +00:00
Gonzalo Paniagua Javier ef06a7c25b 2009-06-02 Gonzalo Paniagua Javier <[email protected]>
* HttpConnection.cs: unbind the context after every read for keep-alive
	connections.
	Bug #502274 fixed.


svn path=/trunk/mcs/; revision=135241
2009-06-02 21:42:31 +00:00
Gonzalo Paniagua Javier 3f8bc3c7ef 2009-01-15 Gonzalo Paniagua Javier <[email protected]>
* HttpListenerRequest.cs: always initialize 'version'.
	* HttpConnection.cs: the socket might already be disconnected when
	shutting down.


svn path=/trunk/mcs/; revision=123453
2009-01-15 06:03:51 +00:00
Gonzalo Paniagua Javier 538c44650f 2009-01-13 Gonzalo Paniagua Javier <[email protected]>
* HttpConnection.cs: we were not writing the headers for 0-length
	responses.
	* WebConnectionStream.cs: for 204/304 responses with an explicit
	content-length of 0, release the socket only once.
	Fixes bug #465638.


svn path=/trunk/mcs/; revision=123250
2009-01-13 20:32:26 +00:00
Gonzalo Paniagua Javier 370451c2fe 2008-11-18 Gonzalo Paniagua Javier <[email protected]>
* HttpConnection.cs: remove CWL. When reusing, BeginReadRequest might
	throw if the client closes.
	* HttpListenerResponse.cs: close the connection for 1.0 clients.


svn path=/trunk/mcs/; revision=119225
2008-11-18 21:50:44 +00:00
Gonzalo Paniagua Javier f374f900d4 2008-10-08 Gonzalo Paniagua Javier <[email protected]>
* HttpConnection.cs:
	* HttpListenerResponse.cs: fix typo that caused the "connection close"
	header to be sent. Do not close the socket when the encoding is not
	chunked and reuse is possible.
	Fixes bug #433371.


svn path=/trunk/mcs/; revision=115250
2008-10-08 17:52:29 +00:00
Miguel de Icaza d97ed80f3b 2008-09-12 Miguel de Icaza <[email protected]>
* HttpListenerPrefixCollection.cs, EndPointListener.cs,
	HttpListener.cs, EndPointManager.cs, HttpConnection.cs: Remove
	generics support where necessary to allow this code to be reused
	in the 1.0 profile.

svn path=/trunk/mcs/; revision=112922
2008-09-12 23:59:52 +00:00
Zoltan Varga c514358e22 2008-02-21 Zoltan Varga <[email protected]>
* HttpConnection.cs (Close): Close the socket even if Shutdown throws an exception.

svn path=/trunk/mcs/; revision=96331
2008-02-21 11:04:49 +00:00
Marek Safar e61dde083e Warnings cleanup
svn path=/trunk/mcs/; revision=89678
2007-11-15 14:14:49 +00:00
Sebastien Pouliot 7da033a75a Fix build as HttpListener now depends on X509Certificate2, which can't be build on the first time for 2.0... bla bla bla, and lot of other stuff depends on it
svn path=/trunk/mcs/; revision=69982
2006-12-23 04:34:08 +00:00