[Mono-dev] Re: Patch for some classes from System.Runtime.Remoting.Channels.Http namespace

Lluis Sanchez lluis at ximian.com
Mon Oct 31 04:55:46 EST 2005


Comments inline

> Hi all,
> I fixed the HttpRemotingHandlerFactory, HttpRemotingHandler,
> HttpServerChannel classes to 
> work properly with a WebServer hosting.
> The HttpRemotingHandlerFactory should first configure the remoting
> infrastructure from the Web.config.
> In case of appropriate Http channel is not registered, the
> HttpRemotingHandlerFactory should create 
> such one and register with ChannelServices.
> In the HttpRemotingHandler I added code to remove extra '/' character
> from the URI.
> I also added the code to send response headers.
> The HttpServerChannel should initialize the port field to the value
> differ from 0, because it 
> requires different handling if the user set port to 0 or not. If the
> port is not changed by the user, 
> the HttpServerChannel should not start the listener.
> In the HttpServerTransportSink.ServiceRequest I handled the case when
> exception was thrown during request
> dispatching (for example, during deserialization of the message). In
> this case the response was not sent at all
> and the client was hang.
> The HttpClientChannel contains only TARGET_JVM change.
> 
> Please, confirm the patches.
> 
> Thanks,
> Svetlana
> 
> Index: HttpRemotingHandlerFactory.cs
> ===================================================================
> --- HttpRemotingHandlerFactory.cs       (revision 52268)
> +++ HttpRemotingHandlerFactory.cs       (working copy)
> @@ -62,27 +62,54 @@
>                         {
>                                 if (webConfigLoaded) return;
>                                 
> +                               try
> +                               {
> +                                       //Configure Web.config
> +                                       String cfg =
> AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
> +                                       System.Runtime.Remoting.RemotingConfiguration.Configure(cfg);
> +                               }
> +                               catch(Exception e) 
> +                               {
> +#if DEBUG
> +                                       Console.WriteLine("ERROR in
> RemotingConfiguration.Configure() {0},{1}",e.GetType(), e.Message);
> +#endif
> +                               }
> +                       

Remoting configuration is being loaded in WebConfigurationSettings.cs,
so it is not necessary to do it here. Just remove:

#if !TARGET_JVM // no remoting support yet in Grasshopper
				RemotingConfiguration.Configure (wcfile);
#endif

in that file (it's in System.Web).


> +
> +                               if (chook == null)
> +                               {
> +                                       HttpChannel chan = new
> HttpChannel();
> +                                       ChannelServices.RegisterChannel(chan);
> +                                       chook = chan;
> +                               }

What is this needed for?

> 
> Index: HttpServerChannel.cs
> ===================================================================
> --- HttpServerChannel.cs        (revision 52268)
> +++ HttpServerChannel.cs        (working copy)
> @@ -58,7 +58,7 @@
>                 private int               _channelPriority = 1;  //
> priority of channel (default=1)
>                 private String            _channelName = "http"; //
> channel name
>                 private String            _machineName = null;   //
> machine name
> -               private int               _port = 0;            //
> port to listen on
> +               private int               _port = -1;            //

Why this? isn't the default behavior of the HttpChannel to listen in any
available port in MS.NET?

> Index: HttpClientChannel.cs
> ===================================================================
> --- HttpClientChannel.cs        (revision 52268)
> +++ HttpClientChannel.cs        (working copy)
> @@ -589,7 +589,13 @@
>                         catch (WebException ex)
>                         {
>                                 httpWebResponse = ex.Response as
> HttpWebResponse;
> -                               if (httpWebResponse == null ||
> httpWebResponse.StatusCode == HttpStatusCode.InternalServerError)
> throw ex;
> +                               if (httpWebResponse == null || 
> +#if !TARGET_JVM
> +                                       httpWebResponse.StatusCode ==
> HttpStatusCode.InternalServerError) 
> +#else
> +                                       httpWebResponse.StatusCode <
> HttpStatusCode.InternalServerError) 
> +#endif

Why is this needed?

Thanks,
Lluis.





More information about the Mono-devel-list mailing list