Close() public method

public Close ( ) : void
return void
Example #1
0
		protected Message CreatePostMessage (HttpContextInfo ctxi)
		{
			if (ctxi.Response.StatusCode != 200) { // it's already invalid.
				ctxi.Close ();
				return null;
			}

			if (!Encoder.IsContentTypeSupported (ctxi.Request.ContentType)) {
				ctxi.Response.StatusCode = (int) HttpStatusCode.UnsupportedMediaType;
				ctxi.Response.StatusDescription = String.Format (
						"Expected content-type '{0}' but got '{1}'", Encoder.ContentType, ctxi.Request.ContentType);
				ctxi.Close ();

				return null;
			}

			// FIXME: supply maxSizeOfHeaders.
			int maxSizeOfHeaders = 0x10000;

#if false // FIXME: enable it, once duplex callback test gets passed.
			Stream stream = ctxi.Request.InputStream;
			if (source.Source.TransferMode == TransferMode.Buffered) {
				if (ctxi.Request.ContentLength64 <= 0)
					throw new ArgumentException ("This HTTP channel is configured to use buffered mode, and thus expects Content-Length sent to the listener");
				long size = 0;
				var ms = new MemoryStream ();
				var buf = new byte [0x1000];
				while (size < ctxi.Request.ContentLength64) {
					if ((size += stream.Read (buf, 0, 0x1000)) > source.Source.MaxBufferSize)
						throw new QuotaExceededException ("Message quota exceeded");
					ms.Write (buf, 0, (int) (size - ms.Length));
				}
				ms.Position = 0;
				stream = ms;
			}

			var msg = Encoder.ReadMessage (
				stream, maxSizeOfHeaders, ctxi.Request.ContentType);
#else
			var msg = Encoder.ReadMessage (
				ctxi.Request.InputStream, maxSizeOfHeaders, ctxi.Request.ContentType);
#endif

			if (MessageVersion.Envelope.Equals (EnvelopeVersion.Soap11) ||
			    MessageVersion.Addressing.Equals (AddressingVersion.None)) {
				string action = GetHeaderItem (ctxi.Request.Headers ["SOAPAction"]);
				if (action != null) {
					if (action.Length > 2 && action [0] == '"' && action [action.Length] == '"')
						action = action.Substring (1, action.Length - 2);
					msg.Headers.Action = action;
				}
			}

			return msg;
		}
Example #2
0
        protected Message CreatePostMessage(HttpContextInfo ctxi)
        {
            if (ctxi.Response.StatusCode != 200)               // it's already invalid.
            {
                ctxi.Close();
                return(null);
            }

            if (!Encoder.IsContentTypeSupported(ctxi.Request.ContentType))
            {
                ctxi.Response.StatusCode        = (int)HttpStatusCode.UnsupportedMediaType;
                ctxi.Response.StatusDescription = String.Format(
                    "Expected content-type '{0}' but got '{1}'", Encoder.ContentType, ctxi.Request.ContentType);
                ctxi.Close();

                return(null);
            }

            // FIXME: supply maxSizeOfHeaders.
            int maxSizeOfHeaders = 0x10000;

#if false // FIXME: enable it, once duplex callback test gets passed.
            Stream stream = ctxi.Request.InputStream;
            if (source.Source.TransferMode == TransferMode.Buffered)
            {
                if (ctxi.Request.ContentLength64 <= 0)
                {
                    throw new ArgumentException("This HTTP channel is configured to use buffered mode, and thus expects Content-Length sent to the listener");
                }
                long size = 0;
                var  ms   = new MemoryStream();
                var  buf  = new byte [0x1000];
                while (size < ctxi.Request.ContentLength64)
                {
                    if ((size += stream.Read(buf, 0, 0x1000)) > source.Source.MaxBufferSize)
                    {
                        throw new QuotaExceededException("Message quota exceeded");
                    }
                    ms.Write(buf, 0, (int)(size - ms.Length));
                }
                ms.Position = 0;
                stream      = ms;
            }

            var msg = Encoder.ReadMessage(
                stream, maxSizeOfHeaders, ctxi.Request.ContentType);
#else
            var msg = Encoder.ReadMessage(
                ctxi.Request.InputStream, maxSizeOfHeaders, ctxi.Request.ContentType);
#endif

            if (MessageVersion.Envelope.Equals(EnvelopeVersion.Soap11) ||
                MessageVersion.Addressing.Equals(AddressingVersion.None))
            {
                string action = GetHeaderItem(ctxi.Request.Headers ["SOAPAction"]);
                if (action != null)
                {
                    if (action.Length > 2 && action [0] == '"' && action [action.Length] == '"')
                    {
                        action = action.Substring(1, action.Length - 2);
                    }
                    msg.Headers.Action = action;
                }
            }
            msg.Properties.Add(RemoteEndpointMessageProperty.Name, new RemoteEndpointMessageProperty(ctxi.Request.ClientIPAddress, ctxi.Request.ClientPort));

            return(msg);
        }
Example #3
0
		protected Message CreatePostMessage (HttpContextInfo ctxi)
		{
			if (ctxi.Response.StatusCode != 200) { // it's already invalid.
				ctxi.Close ();
				return null;
			}

			if (!Encoder.IsContentTypeSupported (ctxi.Request.ContentType)) {
				ctxi.Response.StatusCode = (int) HttpStatusCode.UnsupportedMediaType;
				ctxi.Response.StatusDescription = String.Format (
						"Expected content-type '{0}' but got '{1}'", Encoder.ContentType, ctxi.Request.ContentType);
				ctxi.Close ();

				return null;
			}

			// FIXME: supply maxSizeOfHeaders.
			int maxSizeOfHeaders = 0x10000;

			var msg = Encoder.ReadMessage (
				ctxi.Request.InputStream, maxSizeOfHeaders, ctxi.Request.ContentType);

			if (MessageVersion.Envelope.Equals (EnvelopeVersion.Soap11) ||
			    MessageVersion.Addressing.Equals (AddressingVersion.None)) {
				string action = GetHeaderItem (ctxi.Request.Headers ["SOAPAction"]);
				if (action != null) {
					if (action.Length > 2 && action [0] == '"' && action [action.Length] == '"')
						action = action.Substring (1, action.Length - 2);
					msg.Headers.Action = action;
				}
			}

			return msg;
		}