|
楼主 |
发表于 2014-7-3 17:46:03
|
显示全部楼层
发下.netframework中的一些源码
public class HttpWebRequest : WebRequest, ISerializable
{
//其中一个方法
private void SubmitRequest(ServicePoint servicePoint);
};
private void SubmitRequest(ServicePoint servicePoint)
{
if (!this.Async)
{
this._ConnectionAResult = new LazyAsyncResult(this, null, null);
this._ConnectionReaderAResult = new LazyAsyncResult(this, null, null);
this.OpenWriteSideResponseWindow();
}
if ((this._Timer == null) && !this.Async)
{
this._Timer = this.TimerQueue.CreateTimer(s_TimeoutCallback, this);
}
try
{
if ((this._SubmitWriteStream != null) && this._SubmitWriteStream.IsPostStream)
{
if ((this._OldSubmitWriteStream == null) && !this._SubmitWriteStream.ErrorInStream)
{
this._OldSubmitWriteStream = this._SubmitWriteStream;
}
this._WriteBuffer = null;
}
this.m_Retry = false;
if (this.PreAuthenticate)
{
if ((this.UsesProxySemantics && (this._Proxy != null)) && (this._Proxy.Credentials != null))
{
this.ProxyAuthenticationState.PreAuthIfNeeded(this, this._Proxy.Credentials);
}
if (this.Credentials != null)
{
this.ServerAuthenticationState.PreAuthIfNeeded(this, this.Credentials);
}
}
if (this.WriteBuffer == null)
{
this.UpdateHeaders();
}
if (!this.CheckCacheRetrieveBeforeSubmit())
{
servicePoint.SubmitRequest(this, this.GetConnectionGroupLine());
}
}
finally
{
if (!this.Async)
{
this.CheckWriteSideResponseProcessing();
}
}
}
internal void SubmitRequest(HttpWebRequest request, string connName)
{
Connection connection;
ConnectionGroup group;
bool forcedsubmit = false;
lock (this)
{
group =this.FindConnectionGroup(connName, false);
}
do
{
connection = group.FindConnection(request, connName, out forcedsubmit);
}
while ((connection != null) && !connection.SubmitRequest(request, forcedsubmit));
}
internal class Connection : PooledStream
{
internal void AbortSocket(bool isAbortState);
}
internal void AbortSocket(bool isAbortState)
{
if (isAbortState)
{
this.UnlockRequest();
this.CheckIdle();
}
else
{
this.m_Error = WebExceptionStatus.KeepAliveFailure;
}
lock (this)
{
base.Close(0);
}
}
public void Close(int timeout)
{
Socket abortSocket = this.m_AbortSocket;
Socket socket2 = this.m_AbortSocket6;
this.m_NetworkStream.Close(timeout);
if (abortSocket != null)
{
abortSocket.Close(timeout);
}
if (socket2 != null)
{
socket2.Close(timeout);
}
}
|
|