55 Commits
Author SHA1 Message Date
Martin Baulig 1256d6c8cf Use NetworkStream from CoreFX. (#16889)
* Use `NetworkStream` from CoreFX.

This brings the `NetworkStream` class and related tests from CoreFX.

* `SocketAsyncEventArgs`: partially replace the following properties
  with the CoreFX version: `Buffer`, `BufferList`, `Offset`, `SetBuffer ()`
  as well as the internal `CopyBufferFrom ()`.

* `SocketAsyncResult`: change `Buffer` from `byte[]` to `Memory<byte>`.

* Add internal `Socket` overloads:
   - `Receive (Memory<byte> buffer, int, int, SocketFlags, out SocketError)`
   - `ReceiveFrom (Memory<byte>, int, int, SocketFlags, ref EndPoint, out SocketError)`
   - `SendTo (Memory<byte>, int, int, SocketFlags, EndPoint)`

* Implement async task overloads from CoreFX (`Socket.Tasks.cs`) to `Socket`:
   - `int Read(Span<byte>)`
   - `Task<int> ReadAsync(byte[], int, int, CancellationToken)`
   - `ValueTask<int> ReadAsync(Memory<byte>, CancellationToken)`
   - `int ReadByte()`
   - `void Write(ReadOnlySpan<byte>)`
   - `Task WriteAsync(byte[], int, int, CancellationToken)`
   - `ValueTask WriteAsync(ReadOnlyMemory<byte>, CancellationToken)`
   - `void WriteByte(byte)`

* remove internal unused `PooledStream` and `ConnectionPool` APIs.

* bring new tests from CoreFX:
  - `System.Net.Sockets/tests/FunctionalTests/NetworkStreamTest.cs`
  - `System.Net.Sockets/tests/FunctionalTests/NetworkStreamTest.netcoreapp.cs`

* corlib: add `System.IO.FileSystem` and `System.Net.Sockets` resources and update SR.

* Update Socket.cs

* [csproj] Update project files

* Bump API snapshot submodule
2019-09-19 14:46:29 +02:00
Alexander Köplinger 2d8839e704 [System] Don't throw NIE for ServicePoint.ConnectionLeaseTimeout and .ReceiveBufferSize (#11246)
* [System] Don't throw NIE for ServicePoint.ConnectionLeaseTimeout and .ReceiveBufferSize

Instead return a no-op value. This is the same behavior as .NET Core.

Fixes https://github.com/dotnet/standard/issues/642

* Bump API snapshot submodule
2018-10-19 17:48:23 +02:00
Martin Baulig 89427f4938 [System]: Free ServicePoint instances when they're no longer used. (#8562)
* [System]: Free ServicePoints when they're no longer used.

* Cleanup.

* Don't crash when ServicePoint.CloseConnectionGroup() is called after the ServicePoint has been freed.

* Remove the CloseConnectionGroupConcurrency() test.

This test was for a regression in a piece of code that no longer exist
and the test is poorly designed as it depends on precise timings.
It also attempts to make a web request to a non-exisiting server and
just ignores the error - it is unclear whether that is intentional or not.
2018-05-08 23:21:46 +01:00
Martin Baulig cd09ddbc55 New PR for the new web stack (#6125) 2017-12-14 10:06:47 +01:00
Alexander Kyte b8625e671a [runtime] Always expire a non-resolved hostname's cache
This addresses a regression here:

https://bugzilla.xamarin.com/show_bug.cgi?id=45761

The commits
97e51abfcf and
d35b5d2188

changed control flow such that if the host can't be resolved
and host is set to null, then the later check will return null
for the duration that HasTimedOut is false.
2016-12-21 11:06:03 +01:00
Marek Safar 97e51abfcf [System] Put back handling of direct ip addresses to ServicePoint::HostEntry (removed in 932359f). Fixes #42864 2016-08-16 15:15:05 +02:00
Marek Safar d35b5d2188 [System] Put back handling of direct ip addresses to ServicePoint::HostEntry (removed in 932359f3d6). Fixes #41782 2016-06-16 17:46:18 +02:00
Marek Safar f965a4e5db [System] Internal connectionpool from referencesource 2016-06-02 16:19:42 +02:00
Martin Baulig af01f84119 [System]: Copy 'ServicePoint.Certificate' and 'ClientCertificate' from the referencesource.
(cherry picked from commit 76e0f64862)
2016-03-15 18:45:38 -04:00
Martin Baulig 26d5b83fee [System]: Clone the X509Certificate instance that's stored in ServicePoint.
(cherry picked from commit 65afb9f640)
2016-02-17 20:38:52 -05:00
Martin Baulig 5356284e49 [System]: Remove some dead internal code. 2015-10-21 16:13:29 -04:00
Martin Baulig c8677afffb [System]: Add internal ServicePoint.SetClientCertificate() and SetServerCertificate().
The old SetCertificates() will be removed when merging the rest of
the work-newtls changes.

(cherry picked from commit 815731f2b7fd2f7384b8e16fcaf33f54d5ab6cb1)
2015-10-12 17:19:30 -04:00
Simon Hartmann 932359f3d6 implemented DnsRefreshTimeout to ServicePointManager and adjusted behavior of ServicePoint.HostEntry property.
simplified some calls as requested
2015-09-08 11:08:50 +02:00
Tom Philpot c90f9a9217 Fix NRE in CheckAvailableForRecycling. Fixes #32685 2015-07-31 15:38:35 -07:00
HellBrick 7ee2810f4a Moved WebConnectionGroup.Close() call out of the ServicePoint lock
WebConnectionGroup.Close() calls WebConnection.Close(), which takes connection lock and then takes the service point lock. Calling WebConnectionGroup.Close() leads to taking the service point lock *before* the connection lock, which leads to a deadlock.
2015-03-30 12:45:27 +03:00
Marcos Henrich a769e74c53 [System] Fixed RemoveConnectionGroup concurrent issue.
CloseConnectionGroup can concurrently call RemoveConnectionGroup and remove a group that has added to removeList.
We now check that the group still exists before removing it.
Fixes #19823.
2015-03-18 14:47:42 +00:00
Marcos Henrich 086eff3d60 [System] ServicePoint.CheckAvailableForRecycling is now private. 2015-03-18 14:46:09 +00:00
Marek Safar 9df95ccd67 [system] Remove closed connection groups from service point manager. Fixes #25254 2015-03-10 00:26:13 +01:00
Alexander Köplinger 48e112d652 [Cleanup] Removed TARGET_JVM
It was once part of a special Java target profile, but this is no longer used today.
2014-08-08 03:28:34 +02:00
Martin Baulig f7f1bb819c [Http]: Cleanup and simplify the ServicePoint's connection group list. 2014-05-21 18:47:41 +02:00
Martin Baulig c6a70a9586 Rewrite and fix the web stack's connection reuse and idle logic.
* ServicePoint now uses an idle timer to close idle connections.

* WebConnectionGroup has been mostly rewritten to use a linked
  list of open connections and their idle times.

  This fixes both the problem that we were leaking sockets and
  that we were not reusing existing connections.

* ServicePoint now correctly keeps track of the number of open
  connections.

* ServicePointManager now uses the correct default idle time
  of 100 seconds (previously 15 minutes).

* WebConnection uses the new WebConnectionGroup's busy logic
  to correctly flag connections as busy / reusable.
2014-02-13 14:17:14 +01:00
Miguel de Icaza aee1c0e645 ServicePoint: Use DateTime.UtcNow internally, which avoids looking up the timezone every minute 2013-02-12 00:48:15 -05:00
Miguel de Icaza f48ceb9860 [System] Removal of the NET_2_0 in the source code
Modulo the GUID in the assembly and the GUID embedded in some
field initializers that use the assembly GUID for their name, the
assemblies are idential before and after the patch.
2012-06-02 13:16:40 -04:00
Miguel de Icaza 086885471f Removal of NET_1_1 defines and some NET_2_0; Both defines are true these days in Mono, no versions prior to 2.0 are supported 2012-06-01 18:20:12 -04:00
Gonzalo Paniagua Javier 891af303aa [Socket] Implemented TCP keep alive support
Implemented SetTcpKeepAlive for ServicePoint*.
2011-01-13 18:28:16 -05:00
Sebastien Pouliot 355a27b73d In System.Timers:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* Timer.cs: Removed old NET_2_0 defines and added some new
	MOONLIGHT defines (needed for the client stack)

In System.Net:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* AuthenticationManager.cs: Internal type for Moonlight.
	Add BasicClient, DigestClient, NtlmClient for NET_2_1 since
	this applies to both monotouch and moonlight (client stack).
	Removed unneeded NET_2_0 defines
	* CookieContainer.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll. Removed unneeded NET_2_0
	defines
	* HttpContinueDelegate.cs: Internal type for Moonlight.
	* HttpRequestCreator.cs: Remove a MOONLIGHT define
	* HttpStatusCode.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll
	* HttpWebRequest.cs: Internal type for Moonlight. Change S.Config
	to NET_2_1 defines (applies to both monotouch and moonlight).
	Removed unneeded NET_2_0 and NET_1_1 defines
	* HttpWebResponse.cs: Internal type for Moonlight. Removed 
	unneeded NET_2_0 defines
	* IAuthenticationModule.cs: Internal type for Moonlight.
	* ICertificatePolicy.cs: Internal type for Moonlight.
	* ICredentialPolicy.cs: Internal type for Moonlight. Removed 
	unneeded NET_2_0 defines
	* IWebRequestCreate.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll
	* ServicePoint.cs: Internal type for Moonlight. Change S.Config
	to NET_2_1 defines (applies to both monotouch and moonlight)
	* ServicePointManager.cs: Remove a MOONLIGHT define
	* WebException.cs: For Moonlight it needs to be internal in 
	System.dll and public in System.Net.dll. Removed unneeded NET_2_0
	defines
	* WebHeaderCollection.cs: Internal type for Moonlight. Removed 
	unneeded NET_2_0 defines
	* WebRequest.cs: Internal type for Moonlight. Change S.Config
	to NET_2_1 defines (applies to both monotouch and moonlight)
	* WebResponse.cs: Internal type for Moonlight. Removed unneeded
	NET_2_0 defines

In System.Net.Sockets:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* Socket.cs: Remove some NET_2_0 defines (using) and add a few
	MOONLIGHT defines needed to reuse Socket in the client http stack
	* Socket_2_1.cs: Remove some MOONLIGHT defines
	* SocketAsyncEventArgs.cs: For Moonlight check policy if outside
	System.dll (the client stack use sockets with it's own web 
	xdomain policy)

In System:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* Uri.cs: Remove some MOONLIGHT defines

In .:
2010-03-19  Sebastien Pouliot  <[email protected]>

	* moonlight_*_System.dll.sources: Bring extra types so we can
	build a full, managed, internal HTTP stack to be reused for SL3+
	* Makefile: Add a INSIDE_SYSTEM define when compiling System.dll
	to makes it possible to rebuild the same types in System.Net.dll


svn path=/trunk/mcs/; revision=153916
2010-03-19 19:01:31 +00:00
Jb Evain ba61ae505e use MOONLIGHT symbol
svn path=/trunk/mcs/; revision=153655
2010-03-16 12:07:46 +00:00
Gonzalo Paniagua Javier baa3d5ff39 2009-12-21 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionGroup.cs:
	* ServicePoint.cs: implemented CloseConnectionGroup().


svn path=/trunk/mcs/; revision=148813
2009-12-21 17:12:57 +00:00
Jb Evain f2a6f61bad use a 2.0 network stack for MONOTOUCH
svn path=/trunk/mcs/; revision=139255
2009-08-02 15:43:12 +00:00
Gonzalo Paniagua Javier d0aef15578 2009-07-01 Gonzalo Paniagua Javier <[email protected]>
* WebConnection.cs:
	* ServicePoint.cs: UseNagleAlgorithm determines NoDelay value.


svn path=/trunk/mcs/; revision=137202
2009-07-01 16:49:32 +00:00
Gonzalo Paniagua Javier 61bbe5b41b 2008-10-08 Gonzalo Paniagua Javier <[email protected]>
* WebConnection.cs:
	* ServicePoint.cs:
	* WebConnectionGroup.cs:
	* HttpWebRequest.cs:
	* WebConnectionStream.cs: reuse the same connection when doing NTLM
	authentication. Fixes bug #323375.
	Implemented support for UnsafeAuthenticatedConnectionSharing.


svn path=/trunk/mcs/; revision=115265
2008-10-08 20:16:33 +00:00
Atsushi Eno 526b9e66b9 2007-11-13 Atsushi Enomoto <[email protected]>
* WebRequest.cs : added missing ImpersonationLevel (NIE).
	* SecurityProtocolType.cs : not [Serializable] in 2.0.
	* ServicePoint.cs : no GetHashCode() in 2.0.
	* WebRequestMethods.cs : fixed wrong STOU.
	* FileWebResponse.cs : no Dispose(true) in 2.0 API.


svn path=/trunk/mcs/; revision=89537
2007-11-13 10:06:27 +00:00
Atsushi Eno b572fe6faa 2007-08-09 Atsushi Enomoto <[email protected]>
* HttpWebRequest_2_1.cs, HttpWebResponse_2_1.cs :
	  added new sources for those classes for 2.1 (in 2.1 they are
	  almost abstract, while in 2.0 they are concrete).
	* HttpRequestCreator.cs, ServicePoint.cs :
	  #ifdef 2.0 dependencies out.

	* net_2_1_System.dll.sources :
	  Replaced HttpWebRequest and HttpWebResponse with those for 2.1,
	  and removed related 2.0-only types.


svn path=/trunk/mcs/; revision=83773
2007-08-09 16:57:36 +00:00
Dick Porter d4402975ad 2007-06-28 Chris Howie <[email protected]>
* ServicePoint.cs: Implemented BindIPEndPointDelegate.
	* FtpWebRequest.cs: Respect ServicePoint.BindIPEndPointDelegate.
	* WebConnection.cs: Respect ServicePoint.BindIPEndPointDelegate.

2007-06-28  Chris Howie  <[email protected]>

	* ServicePointTest.cs: Add some loose tests for
	ServicePoint.BindIPEndPointDelegate.


svn path=/trunk/mcs/; revision=83666
2007-08-08 13:14:21 +00:00
Dick Porter 6b41703ee1 2007-06-21 Dick Porter <[email protected]>
* AuthenticationManager.cs: 
	* FtpWebRequest.cs: 
	* Cookie.cs: 
	* ServicePoint.cs: 
	* WebClient.cs: 
	* Authorization.cs: 
	* FileWebRequest.cs: 
	* HttpWebRequest.cs: 
	* WebResponse.cs: 
	* ServicePointManager.cs: 
	* HttpWebResponse.cs: Throw NotImplementedException indirectly, to
	reduce noise in Moma reports.



svn path=/trunk/mcs/; revision=80484
2007-06-21 15:24:34 +00:00
Dick Porter fa277dafe1 2007-06-19 Dick Porter <[email protected]>
* AuthenticationManager.cs: 
	* IWebProxyScript.cs: 
	* Authorization.cs: 
	* Cookie.cs: 
	* CookieException.cs: 
	* CredentialCache.cs: 
	* FileWebRequest.cs: 
	* WebRequest.cs: 
	* FileWebResponse.cs: 
	* WebResponse.cs: 
	* FtpWebRequest.cs: 
	* HttpWebRequest.cs: 
	* DecompressionMethods.cs: 
	* HttpWebResponse.cs: 
	* ProtocolViolationException.cs: 
	* ServicePoint.cs: 
	* ServicePointManager.cs: 
	* WebClient.cs: 
	* WebException.cs: 
	* WebHeaderCollection.cs: 
	* WebProxy.cs: 
	* WebExceptionStatus.cs: 2.0 profile updates



svn path=/trunk/mcs/; revision=80152
2007-06-19 13:23:16 +00:00
Adar Wesley 831089227a 2007-05-16 Adar Wesley <[email protected]>
* System20.csproj: added classes to compilation set IOControlCode.cs,
	IPPacketInformation.cs

	* CookieCollection.cs: added missing method strongly typed CopyTo.

	* CredentialCache.cs: added missing methods Add, Remove, GetCredential

	* HttpWebRequest.jvm.cs: added missing ClientCertificates getter.

	* ServicePoint.cs: added missing method CloseConnectionGroup.

	* WebClient.cs: added missing methods OnDownloadProgressChanged,
	OnUploadProgressChanged, GetWebRequest, GetWebResponse

	* WebHeaderCollection.cs: added missing methods IsRestricted, Add,
	Remove, Set.

	* WebProxy.cs: added missing method GetObjectData.

	* Socket.jvm.cs: added missing methods EndDisconnect, IOControl,
	Send 2.0 overloads, Receive 2.0 overloads, ReceiveMessageFrom,
	BeginReceiveMessageFrom, EndReceiveMessageFrom, 
	EndAccept 2.0 overloads, BeginSend, EndSend, BeginReceive, 
	EndReceive, SendFile, BeginSendFile, EndSendFile, Disconnect,
	DuplicateAndClose

svn path=/trunk/mcs/; revision=77472
2007-05-16 12:03:13 +00:00
Konstantin Triger d1b1213b32 * ServicePointManager.cs: correct assignment typo.
* ServicePoint.cs: Remove unneeded locks for getters, add internal setter.

svn path=/trunk/mcs/; revision=68948
2006-12-04 14:08:53 +00:00
Andrew Skiba 901e94e1e8 compile System.dll in GH
svn path=/trunk/mcs/; revision=67512
2006-11-08 12:34:58 +00:00
Gonzalo Paniagua Javier f99652e387 2005-05-03 Gonzalo Paniagua Javier <[email protected]>
* ServicePoint.cs: HostEntry needs to be thread safe.


svn path=/trunk/mcs/; revision=43966
2005-05-03 17:51:42 +00:00
Gonzalo Paniagua Javier 7ce7ccda6c 2005-04-07 Gonzalo Paniagua Javier <[email protected]>
* WebHeaderCollection.cs: added if-modified-since to the list of
	restricted headers.

	* ServicePoint.cs: use a field object when locking.


svn path=/trunk/mcs/; revision=42651
2005-04-07 20:03:43 +00:00
Gonzalo Paniagua Javier 7b5d49ae29 2004-10-04 Gonzalo Paniagua Javier <[email protected]>
* HttpWebRequest.cs: ProxyQuery returns true when we use a proxy without
	tunneling a secure connection.

	* ServicePoint.cs: added UseConnect property.

	* ServicePointManager.cs: set the UseConnect property when we use a http
	proxy for a https connection.

	* WebConnection.cs: setup the tunnled connection when using a proxy and
	https.

svn path=/trunk/mcs/; revision=34682
2004-10-04 20:25:38 +00:00
Duncan Mak 24f5ef2c44 Add MIT license to System.dll
svn path=/trunk/mcs/; revision=30054
2004-06-21 18:02:11 +00:00
Gonzalo Paniagua Javier ec49116c9e 2004-05-13 Gonzalo Paniagua Javier <[email protected]>
* System.Net/HttpWebRequest.cs: added 3 missing properties for 1.1. They
	are not used yet.

	* System.Net/NetConfig.cs: added MaxResponseHeadersLength field.

	* System.Net/ServicePoint.cs:
	* System.Net/ServicePointManager.cs: added missing properties for 1.1.

	* System.Net.Configuration/NetConfigurationHandler.cs: process the
	httpWebRequest node too. Better error checking.

svn path=/trunk/mcs/; revision=27211
2004-05-13 02:26:55 +00:00
Gonzalo Paniagua Javier ce62c7590a Removed Consoles and ^Ms
svn path=/trunk/mcs/; revision=27209
2004-05-13 02:05:19 +00:00
Lluis Sanchez 5b6c491d20 * HttpWebRequest.cs: Use a lock block instead of Monitor.Enter/Exit, so
the lock is released in case of exception (for example, a
	ThreadAbortException). This also "fixes" bug #52417.
	Beware, this requires a runtime update (due to a bug in Monitor.Exit).
	* ServicePoint.cs: Changed method from internal to private, since it is not
	called from outside the class.

svn path=/trunk/mcs/; revision=24704
2004-03-29 12:17:03 +00:00
Gonzalo Paniagua Javier 167ad12050 2004-02-26 Gonzalo Paniagua Javier <[email protected]>
* ServicePoint.cs: SendContinue is always false for HTTP/1.0

	* WebConnection.cs: get rid of WaitForContinue() (yes!) and prevent
	calling more the ContinueDelegate more than once when we get the
	headers in several packets.

	* WebConnectionStream.cs: removed call to WaitForContinue.

svn path=/trunk/mcs/; revision=23477
2004-02-26 01:35:43 +00:00
Sebastien Pouliot 4024cd5c4c 2004-02-18 Sebastien Pouliot <[email protected]>
* SecurityProtocolType.cs: Added missing [Serializable] to enum. Added
	Default and Ssl2 to NET_1_2 profile. Enum is now internal for NET_1_0
	profile (as we need it for SslClientStream).
	* ServicePoint.cs: Added internal SetCertificates(client,server).
	* ServicePointManager.cs: Added CheckCertificateRevocationList and
	CheckCertificateRevocationList static properties (public in 1.1,
	internal for 1.0).
	* WebConnection.cs: Dynamically creates a SslClientStream (from
	Mono.Security assembly) in case of https. Changed NetworkStream to
	Stream everywhere.

svn path=/trunk/mcs/; revision=23225
2004-02-18 17:58:22 +00:00
Gonzalo Paniagua Javier ed924f816b 2004-02-18 Gonzalo Paniagua Javier <[email protected]>
* HttpWebRequest.cs: send the 'Connection: keep-alive' header when we
	don't know the server version or it's 1.0.

	* ServicePoint.cs: added SetVersion.

	* WebAsyncResult.cs: remove ChunkAsyncResult.

	* WebConnection.cs: set the ServicePoint version when getting a response
	from the server.

	* WebConnectionStream.cs: when posting chunked content, send the head,
	body and trailer of the chunk at once instead of doing 3 separate
	writes, which may cause troubles.

svn path=/trunk/mcs/; revision=23223
2004-02-18 17:14:37 +00:00
Gonzalo Paniagua Javier d3f150312d 2003-10-09 Gonzalo Paniagua Javier <[email protected]>
* System.Net/ServicePoint.cs: preparing for recycling. Not yet finished.
	* System.Net/ServicePointManager.cs: this is the one that reads config.
	* System.Net/WebConnectionGroup.cs: don't read config here.
	* System.Net/WebConnection.cs: added the queue again. Launch queued
	requests on error.
	* System.Net.Configuration/ConnectionManagementHandler.cs: the hashtable
	is case insensitive now.

svn path=/trunk/mcs/; revision=18788
2003-10-09 03:31:08 +00:00