示例#1
0
        public override Stream GetRequestStream()
        {
            bool isPutPost = String.Compare("post", MethodName, true) == 0 ||
                             String.Compare("put", MethodName, true) == 0;

            if (!isPutPost)
            {
                throw new ProtocolViolationException();
            }
            lock (this)
            {
                if (_isAborted)
                {
                    throw new WebException("The operation has been aborted.", WebExceptionStatus.RequestCanceled);
                }
                if (_writeStream != null)
                {
                    return(_writeStream);
                }
                this.OpenConnection();

                //java.io.PipedInputStream inJavaStream = new java.io.PipedInputStream();
                //java.io.PipedOutputStream outJavaStream = new java.io.PipedOutputStream(inJavaStream);

                long contLen = _contentLength;

                OutputStreamRequestEntity reqEntity = new OutputStreamRequestEntity(contLen);

                _writeStream = new VMWRequestStream(reqEntity, contLen);

                EntityEnclosingMethod method = (EntityEnclosingMethod)_method;
                if (AllowWriteStreamBuffering)
                {
                    method.setRequestEntity(reqEntity);
                }
                else if (!AllowWriteStreamBuffering && contLen < 0 && !SendChunked)
                {
                    throw new ProtocolViolationException();
                }
                else
                {
                    method.setRequestEntity(reqEntity);
                }

                _hasRequest = true;
                return(_writeStream);
            }
        }
示例#2
0
		public override Stream GetRequestStream()
		{
			bool isPutPost = String.Compare("post", MethodName, true) == 0 
				|| String.Compare("put", MethodName, true) == 0;
			if(!isPutPost)
				throw new ProtocolViolationException();
			lock(this)
			{
				if (_isAborted)
					throw new WebException ("The operation has been aborted.", WebExceptionStatus.RequestCanceled);
				if(_writeStream != null)
					return _writeStream;
				this.OpenConnection();

				//java.io.PipedInputStream inJavaStream = new java.io.PipedInputStream();
				//java.io.PipedOutputStream outJavaStream = new java.io.PipedOutputStream(inJavaStream);
							
				long contLen = _contentLength;
				
				OutputStreamRequestEntity reqEntity = new OutputStreamRequestEntity(contLen);

				_writeStream = new VMWRequestStream(reqEntity, contLen);
			
				EntityEnclosingMethod method = (EntityEnclosingMethod)_method;
				if(AllowWriteStreamBuffering )
					method.setRequestEntity(reqEntity);
				else if(!AllowWriteStreamBuffering && contLen < 0 && !SendChunked)
					throw new ProtocolViolationException();
				else
					method.setRequestEntity(reqEntity);
			
				_hasRequest = true;
				return _writeStream;
			}
		}