• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Channels.TransportHeaders类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Runtime.Remoting.Channels.TransportHeaders的典型用法代码示例。如果您正苦于以下问题:C# TransportHeaders类的具体用法?C# TransportHeaders怎么用?C# TransportHeaders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TransportHeaders类属于System.Runtime.Remoting.Channels命名空间,在下文中一共展示了TransportHeaders类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ReceiveHeaders

        public static ITransportHeaders ReceiveHeaders(Stream networkStream, byte[] buffer)
        {
            StreamRead (networkStream, buffer, 2);

            byte headerType = buffer [0];
            TransportHeaders headers = new TransportHeaders ();

            while (headerType != 0)
            {
                string key;
                StreamRead (networkStream, buffer, 1);	// byte 1
                switch (headerType)
                {
                    case 4: key = CommonTransportKeys.RequestUri; break;
                    case 6: key = "Content-Type"; break;
                    case 1: key = ReceiveString (networkStream, buffer); break;
                    default: throw new NotSupportedException ("Unknown header code: " + headerType);
                }
                StreamRead (networkStream, buffer, 1);	// byte 1
                headers[key] = ReceiveString (networkStream, buffer);

                StreamRead (networkStream, buffer, 2);
                headerType = buffer [0];
            }

            return headers;
        }
开发者ID:pacificIT,项目名称:smuxi,代码行数:27,代码来源:TcpMessageIO.cs


示例2: AsyncProcessRequest

		public void AsyncProcessRequest (IClientChannelSinkStack sinkStack, IMessage msg,
			ITransportHeaders headers, Stream requestStream)
		{
			TcpConnection connection = null;
			bool isOneWay = RemotingServices.IsOneWay (((IMethodMessage)msg).MethodBase);

			try
			{
				if (headers == null) headers = new TransportHeaders();
				headers [CommonTransportKeys.RequestUri] = ((IMethodMessage)msg).Uri;
				
				// Sends the stream using a connection from the pool
				// and creates a WorkItem that will wait for the
				// response of the server

				connection = TcpConnectionPool.GetConnection (_host, _port);
				TcpMessageIO.SendMessageStream (connection.Stream, requestStream, headers, connection.Buffer);
				connection.Stream.Flush ();

				if (!isOneWay) 
				{
					sinkStack.Push (this, connection);
					ThreadPool.QueueUserWorkItem (new WaitCallback(ReadAsyncTcpMessage), sinkStack);
				}
				else
					connection.Release();
			}
			catch
			{
				if (connection != null) connection.Release();
				if (!isOneWay) throw;
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:33,代码来源:TcpClientTransportSink.cs


示例3: Read

        public IPEndPoint Read(out ITransportHeaders headers, out Stream stream, out IPEndPoint remote)
        {
            // FIXME: 1) reliability 2) exceptions
            remote = new IPEndPoint(IPAddress.Loopback, 0);
            var buffer = UdpClient.Receive(ref remote);

            using (var ms = new MemoryStream(buffer))
            using (var br = new BinaryReader(ms))
            {
                var marker = br.ReadInt16();
                if (marker != HeaderMarker && marker != DataMarker)
                {
                    throw new InvalidDataException("Unexpected datagram format");
                }

                // read transport headers
                headers = new TransportHeaders();
                while (marker != DataMarker)
                {
                    var name = br.ReadString();
                    var value = br.ReadString();
                    headers[name] = value;
                    marker = br.ReadInt16();
                }

                // get response stream
                var length = br.ReadInt32();
                stream = new MemoryStream(buffer, (int)ms.Position, length);
            }

            return remote;
        }
开发者ID:yallie,项目名称:zyan,代码行数:32,代码来源:UdpTransport.cs


示例4: CollectResponseHeaders

 private static ITransportHeaders CollectResponseHeaders(HttpWebResponse response)
 {
     TransportHeaders headers = new TransportHeaders();
     foreach (object obj2 in response.Headers)
     {
         string str = obj2.ToString();
         headers[str] = response.Headers[str];
     }
     return headers;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:HttpClientTransportSink.cs


示例5: AsyncProcessResponse

		public void AsyncProcessResponse (IServerResponseChannelSinkStack sinkStack, object state,
						  IMessage message, ITransportHeaders headers, Stream stream)
		{
			ITransportHeaders responseHeaders = new TransportHeaders();

			if (sinkStack != null) stream = sinkStack.GetResponseStream (message, responseHeaders);
			if (stream == null) stream = new MemoryStream();

			_binaryCore.Serializer.Serialize (stream, message, null);
			if (stream is MemoryStream) stream.Position = 0;

			sinkStack.AsyncProcessResponse (message, responseHeaders, stream);
		}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:13,代码来源:UnixBinaryServerFormatterSink.cs


示例6: AsyncProcessMessage

    public IMessageCtrl AsyncProcessMessage (IMessage msg,
                                             IMessageSink replySink)
    {
      Stream reqStream;
      FormatMessage (msg, out reqStream);

      TransportHeaders reqHeaders = new TransportHeaders();
      ClientChannelSinkStack stack = new ClientChannelSinkStack (replySink);
      stack.Push (this, msg);

      _next.AsyncProcessRequest (stack, msg, reqHeaders, reqStream);

      return null;
    }
开发者ID:emtees,项目名称:old-code,代码行数:14,代码来源:IceClientFormatterSink.cs


示例7: BinaryFormatter

            ServerProcessing IServerChannelSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
            {
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                binaryFormatter.Binder = new GenericsVTSSerializationBinder();
                requestMsg = (IMessage)binaryFormatter.Deserialize(requestStream);
                requestMsg.Properties["__Uri"] = requestHeaders["__RequestUri"];

                next.ProcessMessage(sinkStack, requestMsg, null, null, out responseMsg, out responseHeaders, out responseStream);

                responseHeaders = new TransportHeaders();
                responseStream = new MemoryStream();
                binaryFormatter.Serialize(responseStream, responseMsg);
                responseStream.Position = 0;

                return ServerProcessing.Complete;
            }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:16,代码来源:GenericsVTSSBSinkProvider.cs


示例8: ProcessMessage

 public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
 {
     IPAddress address = requestHeaders["__IPAddress"] as IPAddress;
       Console.Write("Process message from {0} ... ", address);
       if (!this.MatchIPAddress(address) ^ this.m_IsAccept)
       {
     TraceInfoEvent.Raise(string.Format("{0} is accepted by IPFilterChannelSink.", address));
     Console.WriteLine("accepted");
     return this.m_NextSink.ProcessMessage(sinkStack, requestMsg, requestHeaders, requestStream, out responseMsg, out responseHeaders, out responseStream);
       }
       TraceInfoEvent.Raise(string.Format("{0} is rejected by IPFilterChannelSink.", address));
       responseHeaders = new TransportHeaders();
       responseMsg = null;
       responseStream = null;
       return ServerProcessing.Complete;
 }
开发者ID:bmadarasz,项目名称:ndihelpdesk,代码行数:16,代码来源:IPFilterChannelSink.cs


示例9: TransportHeadersIPAddressSerialization

        public void TransportHeadersIPAddressSerialization()
        {
            var ip = IPAddress.Parse("192.168.254.104");
            var th = new TransportHeaders();
            th[CommonTransportKeys.IPAddress] = ip;
            th[CommonTransportKeys.RequestUri] = "localhost";

            var ms = TransportHeaderWrapper.Serialize(th);
            Assert.IsNotNull(ms);

            ms.Position = 0;
            var th2 = TransportHeaderWrapper.Deserialize(ms);
            foreach (System.Collections.DictionaryEntry pair in th)
            {
                Assert.AreEqual(th[pair.Key], th2[pair.Key]);
            }
        }
开发者ID:yallie,项目名称:zyan,代码行数:17,代码来源:TransportHeaderWrapperTests.cs


示例10: TransportHeadersSimpleTypesSerialization

        public void TransportHeadersSimpleTypesSerialization()
        {
            var th = new TransportHeaders();
            th["Hehe"] = 123;
            th["Hoho"] = DateTime.Now;
            th["Haha"] = "localhost";

            var ms = TransportHeaderWrapper.Serialize(th);
            Assert.IsNotNull(ms);

            ms.Position = 0;
            var th2 = TransportHeaderWrapper.Deserialize(ms);
            foreach (System.Collections.DictionaryEntry pair in th)
            {
                Assert.AreEqual(th[pair.Key], th2[pair.Key]);
            }
        }
开发者ID:yallie,项目名称:zyan,代码行数:17,代码来源:TransportHeaderWrapperTests.cs


示例11: InternalProcessMessage

    internal void InternalProcessMessage (Ice.Endpoint replyEp, Stream msgStream, Ice.MessageType mtype)
    {
      // at this point, the ice header has been read, but nothing higher.
      // we don't know very much about this message; we pass it up
      // to (presumably) the formatter for further evaluation

      TransportHeaders headers = new TransportHeaders();
      headers ["__iceMessageType"] = mtype;
      headers ["__iceEndpoint"] = replyEp;

      IMessage respMessage;
      ITransportHeaders respHeaders;
      Stream respStream;

      ServerProcessing res = _next.ProcessMessage (null, null, headers, msgStream,
                                                   out respMessage, out respHeaders,
                                                   out respStream);
      switch (res) {
      case ServerProcessing.Complete:
        if (!(respHeaders != null &&
              respHeaders["__iceNoReply"] != null &&
              ((bool) respHeaders["__iceNoReply"])))
        {
          lock (replyEp.Stream) {
            MemoryStream ms = respStream as MemoryStream;
            ms.WriteTo (replyEp.Stream);
          }
          
        }
        break;
      case ServerProcessing.Async:
        throw new NotImplementedException();
      case ServerProcessing.OneWay:
        // do nothing
        break;
      }
    }
开发者ID:emtees,项目名称:old-code,代码行数:37,代码来源:IceServerTransportSink.cs


示例12: ProcessMessage

        public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack,
            IMessage requestMsg,
            ITransportHeaders requestHeaders, Stream requestStream,
            out IMessage responseMsg, out ITransportHeaders responseHeaders, 
            out Stream responseStream)
        {
            if (requestMsg != null)
            {
                // The message has already been deserialized so delegate to the next sink.
                return _nextSink.ProcessMessage(
                    sinkStack,
                    requestMsg, requestHeaders, requestStream, 
                    out responseMsg, out responseHeaders, out responseStream);
            }
        
            SdlType sdlType;
            if (!ShouldIntercept(requestHeaders, out sdlType))
                return _nextSink.ProcessMessage(sinkStack, null, requestHeaders, requestStream,
                                                out responseMsg, out responseHeaders, out responseStream);            
                        
            // generate sdl and return it
            responseHeaders = new TransportHeaders();
            GenerateSdl(sdlType, sinkStack, requestHeaders, responseHeaders, out responseStream);
            responseMsg = null;

            return ServerProcessing.Complete;            
        } // ProcessMessage
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:27,代码来源:sdlchannelsink.cs


示例13: SendEmptyToClient

        /// <summary>
        /// Erzeugt eine leere Antwortnachricht.
        /// </summary>
        /// <param name="transactionStage">Art des aktuellen Transaktionsschritts</param>
        /// <param name="responseMsg">Antwort-Nachricht</param>
        /// <param name="responseHeaders">Antwort-Header</param>
        /// <param name="responseStream">Antwort-Datenstrom</param>
        /// <returns>Verarbeitungsstatus</returns>
        private ServerProcessing SendEmptyToClient(SecureTransactionStage transactionStage, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            // Inizialisieren
            responseMsg = null;
            responseStream = new MemoryStream();
            responseHeaders = new TransportHeaders();

            // Aktuellen Transaktionsschritt als Antwort-Header schreiben
            responseHeaders[CommonHeaderNames.SECURE_TRANSACTION_STATE] = ((int)transactionStage).ToString();

            // Volständige Verarbeitung zurückmelden
            return ServerProcessing.Complete;
        }
开发者ID:yallie,项目名称:zyan,代码行数:21,代码来源:CryptoServerChannelSink.cs


示例14: MakeSharedKey

        /// <summary>
        /// Erzeugt den gemeinsamen Schlüssel und bereitet dessen Übertragung zum Client vor.
        /// </summary>
        /// <param name="transactID">Sicherheitstransaktionskennung</param>
        /// <param name="requestHeaders">Anfrage-Header vom Client</param>
        /// <param name="responseMsg">Antwortnachricht</param>
        /// <param name="responseHeaders">Antwort-Header</param>
        /// <param name="responseStream">Antwort-Datenstrom</param>
        /// <returns>Status</returns>		
        private ServerProcessing MakeSharedKey(Guid transactID, ITransportHeaders requestHeaders, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            // Gemeinsamer Schlüssel und Inizialisierungsvektor
            SymmetricAlgorithm symmetricProvider = CryptoTools.CreateSymmetricCryptoProvider(_algorithm);

            // Clientverbindungsdaten erzeugen
            ClientConnectionData connectionData = new ClientConnectionData(transactID, symmetricProvider);

            lock (_connections.SyncRoot)
            {
                // Clientverbindungsdaten unter der angegebenen Sicherheitstransaktionskennung speichern
                _connections[transactID.ToString()] = connectionData;
            }
            // RSA Kryptografieanbieter erzeugen
            RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider();

            // Öffentlichen Schlüssel (vom Client) aus den Anfrage-Headern lesen
            string publicKey = (string)requestHeaders[CommonHeaderNames.PUBLIC_KEY];

            // Wenn kein öffentlicher Schlüssel gefunden wurde ...
            if (string.IsNullOrEmpty(publicKey))
                throw new CryptoRemotingException(LanguageResource.CryptoRemotingException_PublicKeyNotFound);

            // Öffentlichen Schlüssel in den Kryptografieanbieter laden
            rsaProvider.FromXmlString(publicKey);

            // Gemeinsamen Schlüssel und dessen Inizialisierungsfaktor verschlüsseln
            byte[] encryptedKey = rsaProvider.Encrypt(symmetricProvider.Key, _oaep);
            byte[] encryptedIV = rsaProvider.Encrypt(symmetricProvider.IV, _oaep);

            // Antwort-Header zusammenstellen
            responseHeaders = new TransportHeaders();
            responseHeaders[CommonHeaderNames.SECURE_TRANSACTION_STATE] = ((int)SecureTransactionStage.SendingSharedKey).ToString();
            responseHeaders[CommonHeaderNames.SHARED_KEY] = Convert.ToBase64String(encryptedKey);
            responseHeaders[CommonHeaderNames.SHARED_IV] = Convert.ToBase64String(encryptedIV);

            // Es wird keine Antwortnachricht benötigt
            responseMsg = null;
            responseStream = new MemoryStream();

            // Vollständige Verarbeitung zurückmelden
            return ServerProcessing.Complete;
        }
开发者ID:yallie,项目名称:zyan,代码行数:52,代码来源:CryptoServerChannelSink.cs


示例15: BuildSoapMessageFromMethodResponse

		// used by the server
		internal object BuildSoapMessageFromMethodResponse(IMethodReturnMessage mrm, out ITransportHeaders responseHeaders)
		{
			responseHeaders = new TransportHeaders();

			if(mrm.Exception == null) {
				// *normal* function return
				
				SoapMessage soapMessage = new SoapMessage();
				
				// fill the transport headers
				responseHeaders["Content-Type"] = "text/xml; charset=\"utf-8\"";

				// build the SoapMessage
				ArrayList paramNames = new ArrayList();
				ArrayList paramValues = new ArrayList();
				ArrayList paramTypes = new ArrayList();
				soapMessage.MethodName = mrm.MethodName+"Response";
				
				Type retType = ((MethodInfo)mrm.MethodBase).ReturnType;
				
				if(retType != typeof(void)) {
					paramNames.Add("return");
					paramValues.Add(mrm.ReturnValue);
					if (mrm.ReturnValue != null)
						paramTypes.Add(mrm.ReturnValue.GetType());
					else
						paramTypes.Add(retType);
				}
				
				for(int i = 0; i < mrm.OutArgCount; i++){
					paramNames.Add(mrm.GetOutArgName(i));
					paramValues.Add(mrm.GetOutArg(i));
					if(mrm.GetOutArg(i) != null) paramTypes.Add(mrm.GetOutArg(i).GetType());
				}
				soapMessage.ParamNames = (string[]) paramNames.ToArray(typeof(string));
				soapMessage.ParamValues = (object[]) paramValues.ToArray(typeof(object));
				soapMessage.ParamTypes = (Type[]) paramTypes.ToArray(typeof(Type));
				soapMessage.XmlNameSpace = _xmlNamespace;
				soapMessage.Headers = BuildMessageHeaders (mrm);
				return soapMessage;
			}
			else {
				// an Exception was thrown while executing the function
				responseHeaders["__HttpStatusCode"] = "500";
				responseHeaders["__HttpReasonPhrase"] = "Bad Request";
				// fill the transport headers
				responseHeaders["Content-Type"] = "text/xml; charset=\"utf-8\"";
				ServerFault serverFault = CreateServerFault(mrm.Exception);
				return new SoapFault("Server", String.Format(" **** {0} - {1}", mrm.Exception.GetType().ToString(), mrm.Exception.Message), null, serverFault);
			}
		}
开发者ID:GuySrinivasan,项目名称:mono,代码行数:52,代码来源:SoapMessageFormatter.cs


示例16: AsyncProcessResponse

		public void AsyncProcessResponse (IServerResponseChannelSinkStack sinkStack, object state,
						  IMessage msg, ITransportHeaders headers, Stream stream)
						  
		{
			ITransportHeaders responseHeaders = new TransportHeaders();

			if(sinkStack != null) stream = sinkStack.GetResponseStream(msg, responseHeaders);
			if(stream == null) stream = new MemoryStream();

			SoapMessageFormatter soapMsgFormatter = (SoapMessageFormatter)state;

			SoapMessage soapMessage = (SoapMessage) soapMsgFormatter.BuildSoapMessageFromMethodResponse((IMethodReturnMessage)msg, out responseHeaders);

			_soapCore.Serializer.Serialize(stream, soapMessage, null);

			if(stream is MemoryStream) stream.Position = 0;
			sinkStack.AsyncProcessResponse (msg, responseHeaders, stream);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:18,代码来源:SoapServerFormatterSink.cs


示例17: AsyncProcessMessage

		public IMessageCtrl AsyncProcessMessage (IMessage msg,
			IMessageSink replySink)
		{
			ITransportHeaders transportHeaders = new TransportHeaders();
			transportHeaders[CommonTransportKeys.RequestUri] = ((IMethodCallMessage)msg).Uri;
			transportHeaders["Content-Type"] = "application/octet-stream";

			Stream stream = _nextInChain.GetRequestStream(msg, transportHeaders);
			if (stream == null) stream = new MemoryStream ();

			_binaryCore.Serializer.Serialize (stream, msg, null);
			if (stream is MemoryStream) stream.Position = 0;

			ClientChannelSinkStack stack = new ClientChannelSinkStack(replySink);
			stack.Push (this, msg);

			_nextInChain.AsyncProcessRequest (stack, msg, transportHeaders, stream);

			// FIXME: No idea about how to implement IMessageCtrl
			return null;	
		}
开发者ID:Profit0004,项目名称:mono,代码行数:21,代码来源:BinaryClientFormatterSink.cs


示例18: lock

        void IClientChannelSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, System.IO.Stream requestStream, out ITransportHeaders responseHeaders, out System.IO.Stream responseStream)
        {
            lock (authHelper)
            {
                if (!authHelper.HaveNonce)
                {
                    System.Runtime.Remoting.Channels.TransportHeaders authHeaders = new TransportHeaders();
                    System.IO.MemoryStream authStream = new System.IO.MemoryStream();
                    authHelper.SetRequest(authHeaders);

                    ITransportHeaders authedHeaders;
                    System.IO.Stream authedStream;
                    nextSink.ProcessMessage(msg, authHeaders, authStream, out authedHeaders, out authedStream);

                    //System.IO.MemoryStream memStream = BaseHelper.ToMemoryStream(authedStream);
                    //char[] chars = new System.Text.UTF8Encoding().GetChars(memStream.ToArray(), 0, (int)memStream.Length);

                    authHelper.SetNonce(authedHeaders);
                }
            }
            authHelper.Authenticate(requestHeaders, ref requestStream);

            nextSink.ProcessMessage(msg, requestHeaders, requestStream, out responseHeaders, out responseStream);
        }
开发者ID:H1GHGuY,项目名称:ServerCheckerV4,代码行数:24,代码来源:ClientAuthenticationSink.cs


示例19: SendRequestForChannel

		private static bool SendRequestForChannel (RequestArguments reqArg, IDictionary HeaderFields, IDictionary CustomHeaders, byte[] buffer)
		{
			TransportHeaders THeaders = new TransportHeaders();

			Stream stream = new MemoryStream(buffer);

			if(stream.Position !=0)
				stream.Seek(0,SeekOrigin.Begin);

			THeaders[CommonTransportKeys.RequestUri] = FixURI((string)HeaderFields["request-url"]);
			THeaders[CommonTransportKeys.ContentType]= HeaderFields["content-type"];
			THeaders[CommonTransportKeys.RequestVerb]= HeaderFields["method"];
			THeaders[CommonTransportKeys.HttpVersion] = HeaderFields["http-version"];
			THeaders[CommonTransportKeys.UserAgent] = HeaderFields["user-agent"];
			THeaders[CommonTransportKeys.Host] = HeaderFields["host"];
			THeaders[CommonTransportKeys.SoapAction] = HeaderFields["SOAPAction"];
			THeaders[CommonTransportKeys.IPAddress] = reqArg.ClientAddress;
			THeaders[CommonTransportKeys.ConnectionId] = reqArg.Id;

			foreach(DictionaryEntry DictEntry in CustomHeaders)
			{
				THeaders[DictEntry.Key.ToString()] = DictEntry.Value.ToString();
			}

			reqArg.Sink.ServiceRequest (reqArg, stream, THeaders);
			return true;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:27,代码来源:HttpServer.cs


示例20: ProcessMessage

        } // StrictBinding



        /// <include file='doc\BinaryFormatterSinks.uex' path='docs/doc[@for="BinaryServerFormatterSink.ProcessMessage"]/*' />
        public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack,
            IMessage requestMsg,
            ITransportHeaders requestHeaders, Stream requestStream,
            out IMessage responseMsg, out ITransportHeaders responseHeaders, 
            out Stream responseStream)
        {
            if (requestMsg != null)
            {
                // The message has already been deserialized so delegate to the next sink.
                return _nextSink.ProcessMessage(
                    sinkStack,
                    requestMsg, requestHeaders, requestStream, 
                    out responseMsg, out responseHeaders, out responseStream);
            }
        
            if (requestHeaders ==  null)
                throw new ArgumentNullException("requestHeaders");

            BaseTransportHeaders wkRequestHeaders = requestHeaders as BaseTransportHeaders;
        
            ServerProcessing processing;
        
            responseHeaders = null;
            responseStream = null;

            String verb = null;
            String contentType = null;

            bool bCanServiceRequest = true;

            // determine the content type
            String contentTypeHeader = null;
            if (wkRequestHeaders != null)
                contentTypeHeader = wkRequestHeaders.ContentType;
            else
                contentTypeHeader = requestHeaders["Content-Type"] as String;
            if (contentTypeHeader != null)
            {
                String charsetValue;
                HttpChannelHelper.ParseContentType(contentTypeHeader,
                                                   out contentType, out charsetValue);
            }

            // check to see if Content-Type matches
            if ((contentType != null) &&
                (String.CompareOrdinal(contentType, CoreChannel.BinaryMimeType) != 0))
            {
                bCanServiceRequest = false;                
            }

            // check for http specific verbs
            if (_protocol == Protocol.Http)
            {
                verb = (String)requestHeaders["__RequestVerb"];    
                if (!verb.Equals("POST") && !verb.Equals("M-POST"))
                    bCanServiceRequest = false;
            }

            // either delegate or return an error message if we can't service the request
            if (!bCanServiceRequest)
            {
                // delegate to next sink if available
                if (_nextSink != null)
                {
                    return _nextSink.ProcessMessage(sinkStack, null, requestHeaders, requestStream,   
                        out responseMsg, out responseHeaders, out responseStream);
                }
                else
                {
                    // send back an error message
                    if (_protocol == Protocol.Http)
                    {
                        // return a client bad request error     
                        responseHeaders = new TransportHeaders();
                        responseHeaders["__HttpStatusCode"] = "400";
                        responseHeaders["__HttpReasonPhrase"] = "Bad Request";
                        responseStream = null;
                        responseMsg = null;
                        return ServerProcessing.Complete;
                    }
                    else
                    {
                        // The transport sink will catch this and do something here.
                        throw new RemotingException(
                            CoreChannel.GetResourceString("Remoting_Channels_InvalidRequestFormat"));
                    }
                }
            }
            

            try
            {
                String objectUri = null;
                if (wkRequestHeaders != null)
                    objectUri = wkRequestHeaders.RequestUri;
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:binaryformattersinks.cs



注:本文中的System.Runtime.Remoting.Channels.TransportHeaders类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Http.HttpChannel类代码示例发布时间:2022-05-26
下一篇:
C# Channels.BinaryServerFormatterSinkProvider类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap