public override void RequestHeaderAvailable( IHttpRequest request, ISessionContext context ) { ServiceLog.Logger.Verbose( () => string.Format( "{0}\r\n=====existing conn======\r\n{1}\r\n========================\r\n", context.Id, Encoding.UTF8.GetString(request.GetBuffer()))); context.SendServerData(request.GetBuffer()); }
public override void RequestHeaderAvailable( IHttpRequest request, ISessionContext context ) { Contract.Requires(context.ClientConnection != null); ServiceLog.Logger.Verbose( () => string.Format( "{0}\r\n========================\r\n{1}\r\n========================\r\n", context.Id, Encoding.UTF8.GetString(request.GetBuffer()))); //string filter = _filter.EvaluateConnectionFilters(request, context.ClientConnection.ConnectionId); //if (filter != null) //{ // ServiceLog.Logger.Info("{0} Connection filtered. Sending response to client.", context.Id); // context.SendClientData(Encoding.UTF8.GetBytes(filter)); // context.ChangeState(SessionStateType.Unconnected); //} //else { if (request.IsSsl) { context.ChangeState(SessionStateType.Https); } else { string host; int port; if (SessionStateUtils.TryParseAddress(request, out host, out port)) { ServiceLog.Logger.Info("{0} Attempting to connect to remote host: [{1}] [{2}]", context.Id, host, port); context.BeginConnectToRemoteHost(host, port); } else { throw new InvalidDataException("Unable to parse host address from HTTP request"); } } } }
private void HandleServerConnect( bool success, IHttpRequest request ) { ServiceLog.Logger.Verbose( "{0} ClientSession -- handle server connect", Id ); try { // Send the header before releasing the connect event. This ensures that the header is sent before // any additional data in the HTTP request body _dispatcher.SendServerData( request.GetBuffer(), HandleServerSend ); _connectToServerEvent.Set(); if ( !success ) { ServiceLog.Logger.Warning( "{0} Unable to connecto to remote host. Facade returned false.", Id ); Reset(); } } catch ( Exception ex ) { ServiceLog.Logger.Exception( string.Format( "{0} Unhandled exception connecting to remote host.", Id ), ex ); Reset(); } }