예제 #1
0
        internal BContentStream createStreamRequest(Stream strm)
        {
            if (streams == null)
            {
                streams = new List <BContentStream>();
            }

            BContentStream bstrm = null;

            if (strm is BContentStream)
            {
                bstrm = (BContentStream)strm;
            }
            else
            {
                bstrm = new BContentStreamWrapper(strm);
            }

            // If the stream has already a streamId, it has been received
            // from the server. In this case, the application obviously
            // wants to forward the stream to another client. Thus
            // we do not have to upload the stream.

            if (bstrm.TargetId.isZero())
            {
                BTargetId targetId = new BTargetId(
                    transport.getConnectedServerId(),
                    header.messageId,
                    transport.getWire().makeMessageId());
                bstrm.TargetId = targetId;
                streams.Add(bstrm);
            }

            return(bstrm);
        }
예제 #2
0
파일: BOutput.cs 프로젝트: marcarvalho/byps
        internal BContentStream createStreamRequest(Stream strm)
        {
            if (streams == null) streams = new List<BContentStream>();

            BContentStream bstrm = null;

            if (strm is BContentStream)
            {
                bstrm = (BContentStream)strm;
            }
            else
            {
                bstrm = new BContentStreamWrapper(strm);
            }

            // If the stream has already a streamId, it has been received
            // from the server. In this case, the application obviously
            // wants to forward the stream to another client. Thus 
            // we do not have to upload the stream.

            if (bstrm.TargetId.isZero())
            {
                BTargetId targetId = new BTargetId(
                    transport.getConnectedServerId(),
                    header.messageId,
                    transport.getWire().makeMessageId());
                bstrm.TargetId = targetId;
                streams.Add(bstrm);
            }

            return bstrm;
        }
예제 #3
0
        public void testRemoteStreamsFileStream()
        {
            log.info("testRemoteStreamsFileStream(");
            String str = "hallo";
            FileInfo file = new FileInfo(Path.GetTempFileName() + ".txt");
            File.WriteAllText(file.FullName, str);
            Stream istrm = new BContentStreamWrapper(file);
            remote.SetImage(istrm);
            BContentStream istrmR = (BContentStream)remote.GetImage();

            TestUtils.assertEquals(log, "Content-Type", "text/plain", istrmR.ContentType);
            TestUtils.assertEquals(log, "Content-Length", file.Length, istrmR.ContentLength);
            TestUtils.assertEquals(log, "Content-Disposition", "inline; filename=" + file.Name, istrmR.ContentDisposition);
            TestUtils.assertEquals(log, "FileName", file.Name, istrmR.FileName);

            ByteBuffer buf = BWire.bufferFromStream(istrmR, false);
            String strR = File.ReadAllText(file.FullName);
            TestUtils.assertEquals(log, "stream", str, strR);

            TestUtils.assertEquals(log, "Content-Type", "text/plain", istrmR.ContentType);
            TestUtils.assertEquals(log, "Content-Length", file.Length, istrmR.ContentLength);
            TestUtils.assertEquals(log, "Content-Disposition", "inline; filename=" + file.Name, istrmR.ContentDisposition);
            TestUtils.assertEquals(log, "FileName", file.Name, istrmR.FileName);

            file.Delete();
            log.info(")testRemoteStreamsFileStream");
        }