Exemple #1
0
 internal StringEncoder(Charset cs, String rcn)
 {
     this.RequestedCharsetName_Renamed = rcn;
     this.Cs        = cs;
     this.Ce        = cs.NewEncoder().OnMalformedInput(CodingErrorAction.REPLACE).OnUnmappableCharacter(CodingErrorAction.REPLACE);
     this.IsTrusted = (cs.GetType().ClassLoader0 == null);
 }
        public virtual ManagedHttpClientConnection Create(HttpRoute route, ConnectionConfig
                                                          config)
        {
            ConnectionConfig  cconfig              = config != null ? config : ConnectionConfig.Default;
            CharsetDecoder    chardecoder          = null;
            CharsetEncoder    charencoder          = null;
            Encoding          charset              = cconfig.GetCharset();
            CodingErrorAction malformedInputAction = cconfig.GetMalformedInputAction() != null
                                 ? cconfig.GetMalformedInputAction() : CodingErrorAction.Report;

            CodingErrorAction unmappableInputAction = cconfig.GetUnmappableInputAction() != null
                                 ? cconfig.GetUnmappableInputAction() : CodingErrorAction.Report;

            if (charset != null)
            {
                chardecoder = charset.NewDecoder();
                chardecoder.OnMalformedInput(malformedInputAction);
                chardecoder.OnUnmappableCharacter(unmappableInputAction);
                charencoder = charset.NewEncoder();
                charencoder.OnMalformedInput(malformedInputAction);
                charencoder.OnUnmappableCharacter(unmappableInputAction);
            }
            string id = "http-outgoing-" + System.Convert.ToString(Counter.GetAndIncrement());

            return(new LoggingManagedHttpClientConnection(id, log, headerlog, wirelog, cconfig
                                                          .GetBufferSize(), cconfig.GetFragmentSizeHint(), chardecoder, charencoder, cconfig
                                                          .GetMessageConstraints(), null, null, requestWriterFactory, responseParserFactory
                                                          ));
        }
Exemple #3
0
 private CharsetEncoder Encoder()
 {
     if (Enc == null)
     {
         Enc = Cs.NewEncoder().OnMalformedInput(CodingErrorAction.REPORT).OnUnmappableCharacter(CodingErrorAction.REPORT);
     }
     return(Enc);
 }
Exemple #4
0
 /// <summary>
 /// Creates an OutputStreamWriter that uses the given charset encoder.
 /// </summary>
 /// <param name="out">
 ///         An OutputStream
 /// </param>
 /// <param name="enc">
 ///         A charset encoder
 ///
 /// @since 1.4
 /// @spec JSR-51 </param>
 public OutputStreamWriter(OutputStream @out, CharsetEncoder enc) : base(@out)
 {
     if (enc == null)
     {
         throw new NullPointerException("charset encoder");
     }
     Se = StreamEncoder.forOutputStreamWriter(@out, this, enc);
 }
        public GenericEncoder(String charsetName)
        {
            super(charsetName);

            _charset = Charset.forName(charsetName);

            _encoder = _charset.newEncoder();
        }
 /// <summary>Creates new instance of SessionOutputBufferImpl.</summary>
 /// <remarks>Creates new instance of SessionOutputBufferImpl.</remarks>
 /// <param name="metrics">HTTP transport metrics.</param>
 /// <param name="buffersize">buffer size. Must be a positive number.</param>
 /// <param name="fragementSizeHint">
 /// fragment size hint defining a minimal size of a fragment
 /// that should be written out directly to the socket bypassing the session buffer.
 /// Value <code>0</code> disables fragment buffering.
 /// </param>
 /// <param name="charencoder">
 /// charencoder to be used for encoding HTTP protocol elements.
 /// If <code>null</code> simple type cast will be used for char to byte conversion.
 /// </param>
 internal SessionOutputBufferImpl(HttpTransportMetricsImpl metrics, int buffersize,
                                  int fragementSizeHint, CharsetEncoder charencoder) : base()
 {
     Args.Positive(buffersize, "Buffer size");
     Args.NotNull(metrics, "HTTP transport metrcis");
     this.metrics           = metrics;
     this.buffer            = new ByteArrayBuffer(buffersize);
     this.fragementSizeHint = fragementSizeHint >= 0 ? fragementSizeHint : 0;
     this.encoder           = charencoder;
 }
Exemple #7
0
 public DefaultManagedHttpClientConnection(string id, int buffersize, int fragmentSizeHint
                                           , CharsetDecoder chardecoder, CharsetEncoder charencoder, MessageConstraints constraints
                                           , ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy
                                           , HttpMessageWriterFactory <IHttpRequest> requestWriterFactory, HttpMessageParserFactory
                                           <HttpResponse> responseParserFactory) : base(buffersize, fragmentSizeHint, chardecoder
                                                                                        , charencoder, constraints, incomingContentStrategy, outgoingContentStrategy, requestWriterFactory
                                                                                        , responseParserFactory)
 {
     this.id         = id;
     this.attributes = new ConcurrentHashMap <string, object>();
 }
Exemple #8
0
 /// <summary>Creates new instance of DefaultBHttpClientConnection.</summary>
 /// <remarks>Creates new instance of DefaultBHttpClientConnection.</remarks>
 /// <param name="buffersize">buffer size. Must be a positive number.</param>
 /// <param name="fragmentSizeHint">fragment size hint.</param>
 /// <param name="chardecoder">
 /// decoder to be used for decoding HTTP protocol elements.
 /// If <code>null</code> simple type cast will be used for byte to char conversion.
 /// </param>
 /// <param name="charencoder">
 /// encoder to be used for encoding HTTP protocol elements.
 /// If <code>null</code> simple type cast will be used for char to byte conversion.
 /// </param>
 /// <param name="constraints">
 /// Message constraints. If <code>null</code>
 /// <see cref="Org.Apache.Http.Config.MessageConstraints.Default">Org.Apache.Http.Config.MessageConstraints.Default
 ///     </see>
 /// will be used.
 /// </param>
 /// <param name="incomingContentStrategy">
 /// incoming content length strategy. If <code>null</code>
 /// <see cref="Org.Apache.Http.Impl.Entity.LaxContentLengthStrategy.Instance">Org.Apache.Http.Impl.Entity.LaxContentLengthStrategy.Instance
 ///     </see>
 /// will be used.
 /// </param>
 /// <param name="outgoingContentStrategy">
 /// outgoing content length strategy. If <code>null</code>
 /// <see cref="Org.Apache.Http.Impl.Entity.StrictContentLengthStrategy.Instance">Org.Apache.Http.Impl.Entity.StrictContentLengthStrategy.Instance
 ///     </see>
 /// will be used.
 /// </param>
 /// <param name="requestWriterFactory">
 /// request writer factory. If <code>null</code>
 /// <see cref="Org.Apache.Http.Impl.IO.DefaultHttpRequestWriterFactory.Instance">Org.Apache.Http.Impl.IO.DefaultHttpRequestWriterFactory.Instance
 ///     </see>
 /// will be used.
 /// </param>
 /// <param name="responseParserFactory">
 /// response parser factory. If <code>null</code>
 /// <see cref="Org.Apache.Http.Impl.IO.DefaultHttpResponseParserFactory.Instance">Org.Apache.Http.Impl.IO.DefaultHttpResponseParserFactory.Instance
 ///     </see>
 /// will be used.
 /// </param>
 internal DefaultBHttpClientConnection(int buffersize, int fragmentSizeHint, CharsetDecoder
                                       chardecoder, CharsetEncoder charencoder, MessageConstraints constraints, ContentLengthStrategy
                                       incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, HttpMessageWriterFactory
                                       <IHttpRequest> requestWriterFactory, HttpMessageParserFactory <HttpResponse> responseParserFactory
                                       ) : base(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints, incomingContentStrategy
                                                , outgoingContentStrategy)
 {
     this.requestWriter = (requestWriterFactory != null ? requestWriterFactory : DefaultHttpRequestWriterFactory
                           .Instance).Create(GetSessionOutputBuffer());
     this.responseParser = (responseParserFactory != null ? responseParserFactory : DefaultHttpResponseParserFactory
                            .Instance).Create(GetSessionInputBuffer(), constraints);
 }
Exemple #9
0
        internal static sbyte[] Encode(Charset cs, char[] ca, int off, int len)
        {
            CharsetEncoder ce = cs.NewEncoder();
            int            en = Scale(len, ce.MaxBytesPerChar());

            sbyte[] ba = new sbyte[en];
            if (len == 0)
            {
                return(ba);
            }
            bool isTrusted = false;

            if (System.SecurityManager != null)
            {
                if (!(isTrusted = (cs.GetType().ClassLoader0 == null)))
                {
                    ca  = Arrays.CopyOfRange(ca, off, off + len);
                    off = 0;
                }
            }
            ce.OnMalformedInput(CodingErrorAction.REPLACE).OnUnmappableCharacter(CodingErrorAction.REPLACE).Reset();
            if (ce is ArrayEncoder)
            {
                int blen = ((ArrayEncoder)ce).encode(ca, off, len, ba);
                return(SafeTrim(ba, blen, cs, isTrusted));
            }
            else
            {
                ByteBuffer bb = ByteBuffer.Wrap(ba);
                CharBuffer cb = CharBuffer.Wrap(ca, off, len);
                try
                {
                    CoderResult cr = ce.Encode(cb, bb, true);
                    if (!cr.Underflow)
                    {
                        cr.ThrowException();
                    }
                    cr = ce.Flush(bb);
                    if (!cr.Underflow)
                    {
                        cr.ThrowException();
                    }
                }
                catch (CharacterCodingException x)
                {
                    throw new Error(x);
                }
                return(SafeTrim(ba, bb.Position(), cs, isTrusted));
            }
        }
Exemple #10
0
        /// <summary>Constructor helper.</summary>
        /// <remarks>Constructor helper.</remarks>
        /// <param name="list">
        /// files in the subtree of the work tree this iterator operates
        /// on
        /// </param>
        protected internal virtual void Init(WorkingTreeIterator.Entry[] list)
        {
            // Filter out nulls, . and .. as these are not valid tree entries,
            // also cache the encoded forms of the path names for efficient use
            // later on during sorting and iteration.
            //
            entries = list;
            int            i;
            int            o;
            CharsetEncoder nameEncoder = state.nameEncoder;

            for (i = 0, o = 0; i < entries.Length; i++)
            {
                WorkingTreeIterator.Entry e = entries[i];
                if (e == null)
                {
                    continue;
                }
                string name = e.GetName();
                if (".".Equals(name) || "..".Equals(name))
                {
                    continue;
                }
                if (Constants.DOT_GIT.Equals(name))
                {
                    continue;
                }
                if (Constants.DOT_GIT_IGNORE.Equals(name))
                {
                    ignoreNode = new WorkingTreeIterator.PerDirectoryIgnoreNode(e);
                }
                if (i != o)
                {
                    entries[o] = e;
                }
                e.EncodeName(nameEncoder);
                o++;
            }
            entryCnt = o;
            Arrays.Sort(entries, 0, entryCnt, ENTRY_CMP);
            contentIdFromPtr = -1;
            ptr = 0;
            if (!Eof)
            {
                ParseEntry();
            }
        }
Exemple #11
0
        internal sbyte[] GetBytes(String s)
        {
            CharsetEncoder ce = Encoder().Reset();

            char[] ca  = s.ToCharArray();
            int    len = (int)(ca.Length * ce.MaxBytesPerChar());

            sbyte[] ba = new sbyte[len];
            if (len == 0)
            {
                return(ba);
            }
            // UTF-8 only for now. Other ArrayDeocder only handles
            // CodingErrorAction.REPLACE mode.
            if (IsUTF8 && ce is ArrayEncoder)
            {
                int blen = ((ArrayEncoder)ce).encode(ca, 0, ca.Length, ba);
                if (blen == -1)                 // malformed
                {
                    throw new IllegalArgumentException("MALFORMED");
                }
                return(Arrays.CopyOf(ba, blen));
            }
            ByteBuffer  bb = ByteBuffer.Wrap(ba);
            CharBuffer  cb = CharBuffer.Wrap(ca);
            CoderResult cr = ce.Encode(cb, bb, true);

            if (!cr.Underflow)
            {
                throw new IllegalArgumentException(cr.ToString());
            }
            cr = ce.Flush(bb);
            if (!cr.Underflow)
            {
                throw new IllegalArgumentException(cr.ToString());
            }
            if (bb.Position() == ba.Length)             // defensive copy?
            {
                return(ba);
            }
            else
            {
                return(Arrays.CopyOf(ba, bb.Position()));
            }
        }
Exemple #12
0
        /// <summary>
        /// Converts the provided String to bytes using the
        /// UTF-8 encoding.
        /// </summary>
        /// <remarks>
        /// Converts the provided String to bytes using the
        /// UTF-8 encoding. If <code>replace</code> is true, then
        /// malformed input is replaced with the
        /// substitution character, which is U+FFFD. Otherwise the
        /// method throws a MalformedInputException.
        /// </remarks>
        /// <returns>
        /// ByteBuffer: bytes stores at ByteBuffer.array()
        /// and length is ByteBuffer.limit()
        /// </returns>
        /// <exception cref="CharacterCodingException"/>
        public static ByteBuffer Encode(string @string, bool replace)
        {
            CharsetEncoder encoder = EncoderFactory.Get();

            if (replace)
            {
                encoder.OnMalformedInput(CodingErrorAction.Replace);
                encoder.OnUnmappableCharacter(CodingErrorAction.Replace);
            }
            ByteBuffer bytes = encoder.Encode(CharBuffer.Wrap(@string.ToCharArray()));

            if (replace)
            {
                encoder.OnMalformedInput(CodingErrorAction.Report);
                encoder.OnUnmappableCharacter(CodingErrorAction.Report);
            }
            return(bytes);
        }
        /// <summary>Creates new instance of BHttpConnectionBase.</summary>
        /// <remarks>Creates new instance of BHttpConnectionBase.</remarks>
        /// <param name="buffersize">buffer size. Must be a positive number.</param>
        /// <param name="fragmentSizeHint">fragment size hint.</param>
        /// <param name="chardecoder">
        /// decoder to be used for decoding HTTP protocol elements.
        /// If <code>null</code> simple type cast will be used for byte to char conversion.
        /// </param>
        /// <param name="charencoder">
        /// encoder to be used for encoding HTTP protocol elements.
        /// If <code>null</code> simple type cast will be used for char to byte conversion.
        /// </param>
        /// <param name="constraints">
        /// Message constraints. If <code>null</code>
        /// <see cref="Org.Apache.Http.Config.MessageConstraints.Default">Org.Apache.Http.Config.MessageConstraints.Default
        ///     </see>
        /// will be used.
        /// </param>
        /// <param name="incomingContentStrategy">
        /// incoming content length strategy. If <code>null</code>
        /// <see cref="Org.Apache.Http.Impl.Entity.LaxContentLengthStrategy.Instance">Org.Apache.Http.Impl.Entity.LaxContentLengthStrategy.Instance
        ///     </see>
        /// will be used.
        /// </param>
        /// <param name="outgoingContentStrategy">
        /// outgoing content length strategy. If <code>null</code>
        /// <see cref="Org.Apache.Http.Impl.Entity.StrictContentLengthStrategy.Instance">Org.Apache.Http.Impl.Entity.StrictContentLengthStrategy.Instance
        ///     </see>
        /// will be used.
        /// </param>
        internal BHttpConnectionBase(int buffersize, int fragmentSizeHint, CharsetDecoder
                                     chardecoder, CharsetEncoder charencoder, MessageConstraints constraints, ContentLengthStrategy
                                     incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy) : base(
                )
        {
            Args.Positive(buffersize, "Buffer size");
            HttpTransportMetricsImpl inTransportMetrics  = new HttpTransportMetricsImpl();
            HttpTransportMetricsImpl outTransportMetrics = new HttpTransportMetricsImpl();

            this.inbuffer = new SessionInputBufferImpl(inTransportMetrics, buffersize, -1, constraints
                                                       != null ? constraints : MessageConstraints.Default, chardecoder);
            this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, buffersize, fragmentSizeHint
                                                         , charencoder);
            this.connMetrics = new HttpConnectionMetricsImpl(inTransportMetrics, outTransportMetrics
                                                             );
            this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy
                                 : LaxContentLengthStrategy.Instance;
            this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy
                                 : StrictContentLengthStrategy.Instance;
        }
Exemple #14
0
        /// <summary>
        /// Creates a new XML encoder to write out <em>JavaBeans</em>
        /// to the stream <code>out</code> using the given <code>charset</code>
        /// starting from the given <code>indentation</code>.
        /// </summary>
        /// <param name="out">          the stream to which the XML representation of
        ///                     the objects will be written </param>
        /// <param name="charset">      the name of the requested charset;
        ///                     may be either a canonical name or an alias </param>
        /// <param name="declaration">  whether the XML declaration should be generated;
        ///                     set this to <code>false</code>
        ///                     when embedding the contents in another XML document </param>
        /// <param name="indentation">  the number of space characters to indent the entire XML document by
        /// </param>
        /// <exception cref="IllegalArgumentException">
        ///          if <code>out</code> or <code>charset</code> is <code>null</code>,
        ///          or if <code>indentation</code> is less than 0
        /// </exception>
        /// <exception cref="IllegalCharsetNameException">
        ///          if <code>charset</code> name is illegal
        /// </exception>
        /// <exception cref="UnsupportedCharsetException">
        ///          if no support for the named charset is available
        ///          in this instance of the Java virtual machine
        /// </exception>
        /// <exception cref="UnsupportedOperationException">
        ///          if loaded charset does not support encoding
        /// </exception>
        /// <seealso cref= Charset#forName(String)
        ///
        /// @since 1.7 </seealso>
        public XMLEncoder(OutputStream @out, String charset, bool declaration, int indentation)
        {
            if (@out == null)
            {
                throw new IllegalArgumentException("the output stream cannot be null");
            }
            if (indentation < 0)
            {
                throw new IllegalArgumentException("the indentation must be >= 0");
            }
            Charset cs = Charset.ForName(charset);

            this.Encoder          = cs.NewEncoder();
            this.Charset          = charset;
            this.Declaration      = declaration;
            this.Indentation      = indentation;
            this.@out             = new OutputStreamWriter(@out, cs.NewEncoder());
            ValueToExpression     = new IdentityHashMap <>();
            TargetToStatementList = new IdentityHashMap <>();
            NameGenerator         = new NameGenerator();
        }
Exemple #15
0
            internal virtual void EncodeName(CharsetEncoder enc)
            {
                ByteBuffer b;

                try
                {
                    b = enc.Encode(CharBuffer.Wrap(GetName()));
                }
                catch (CharacterCodingException)
                {
                    // This should so never happen.
                    throw new RuntimeException(MessageFormat.Format(JGitText.Get().unencodeableFile,
                                                                    GetName()));
                }
                encodedNameLen = b.Limit();
                if (b.HasArray() && b.ArrayOffset() == 0)
                {
                    encodedName = ((byte[])b.Array());
                }
                else
                {
                    b.Get(encodedName = new byte[encodedNameLen]);
                }
            }
Exemple #16
0
        /// <summary>
        /// Constructs a writer that encodes characters using the given encoder and
        /// writes the resulting bytes to the given channel.
        ///
        /// <para> The resulting stream will contain an internal output buffer of at
        /// least <tt>minBufferCap</tt> bytes.  The stream's <tt>write</tt> methods
        /// will, as needed, flush the buffer by writing bytes to the underlying
        /// channel; if the channel is in non-blocking mode when bytes are to be
        /// written then an <seealso cref="IllegalBlockingModeException"/> will be thrown.
        /// The resulting stream will not otherwise be buffered.  Closing the stream
        /// will in turn cause the channel to be closed.  </para>
        /// </summary>
        /// <param name="ch">
        ///         The channel to which bytes will be written
        /// </param>
        /// <param name="enc">
        ///         The charset encoder to be used
        /// </param>
        /// <param name="minBufferCap">
        ///         The minimum capacity of the internal byte buffer,
        ///         or <tt>-1</tt> if an implementation-dependent
        ///         default capacity is to be used
        /// </param>
        /// <returns>  A new writer </returns>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public static java.io.Writer newWriter(final WritableByteChannel ch, final java.nio.charset.CharsetEncoder enc, final int minBufferCap)
        public static Writer NewWriter(WritableByteChannel ch, CharsetEncoder enc, int minBufferCap)
        {
            CheckNotNull(ch, "ch");
            return(StreamEncoder.forEncoder(ch, enc.Reset(), minBufferCap));
        }
Exemple #17
0
 internal IteratorState(WorkingTreeOptions options)
 {
     this.options     = options;
     this.nameEncoder = Constants.CHARSET.NewEncoder();
 }
 public LoggingManagedHttpClientConnection(string id, Log log, Log headerlog, Log
                                           wirelog, int buffersize, int fragmentSizeHint, CharsetDecoder chardecoder, CharsetEncoder
                                           charencoder, MessageConstraints constraints, ContentLengthStrategy incomingContentStrategy
                                           , ContentLengthStrategy outgoingContentStrategy, HttpMessageWriterFactory <IHttpRequest
                                                                                                                      > requestWriterFactory, HttpMessageParserFactory <HttpResponse> responseParserFactory
                                           ) : base(id, buffersize, fragmentSizeHint, chardecoder, charencoder, constraints
                                                    , incomingContentStrategy, outgoingContentStrategy, requestWriterFactory, responseParserFactory
                                                    )
 {
     this.log       = log;
     this.headerlog = headerlog;
     this.wire      = new Wire(wirelog, id);
 }
Exemple #19
0
        public BoundaryTy readBody(TextReader rr, EML_Media parent)
        {
            mlBody   = null;
            mlBinary = null;

            string major = mlContentType.major;

            string boundary = parent.mlContentType.boundary;

            bool binaryMedia = !major.Equals("text");

            string         charSet     = mlContentType.charSet;
            CharsetEncoder charSet_enc = charSetEnc.getEncoding(charSet);

            if (charSet_enc == null)
            {
                throw new ArgumentException("不明な文字コード", charSet);
            }

            string          transferEncoding = parent.mlContentTransferEncoding.major;
            TransferEncoder transfer_enc     = transferEnc.getEncoding(transferEncoding);

            if (transfer_enc == null)
            {
                throw new ArgumentException("不明な変換コード", transferEncoding);
            }

            mlBody   = new StringBuilder();
            mlBinary = new MemoryStream();

            String boundaryPass = (boundary != null)
                ? "--" + boundary
                : null
            ;
            String boundaryTerm = (boundary != null)
                ? "--" + boundary + "--"
                : null
            ;

            MemoryStream tempText = new MemoryStream();

            bool preserveCRLF = transfer_enc.preserveCRLF;

            ArrayList  alDEBUG = new ArrayList();
            BoundaryTy bty     = BoundaryTy.Pass;

            while (true)
            {
                string lin = rr.ReadLine();
                if (lin == null)
                {
                    break;
                }
                alDEBUG.Add(lin);
                if (boundaryTerm != null && lin.Equals(boundaryTerm))
                {
                    bty = BoundaryTy.Term;
                    break;
                }
                if (boundaryPass != null && lin.Equals(boundaryPass))
                {
                    break;
                }
                byte[] bin = transfer_enc.decodeBinary(lin);
                if (binaryMedia)
                {
                    mlBinary.Write(bin, 0, bin.Length);
                    if (preserveCRLF)
                    {
                        mlBinary.WriteByte((byte)'\r');
                        mlBinary.WriteByte((byte)'\n');
                    }
                    continue;
                }
                tempText.Write(bin, 0, bin.Length);
                if (preserveCRLF)
                {
                    tempText.WriteByte((byte)'\r');
                    tempText.WriteByte((byte)'\n');
                }
            }
            if (!binaryMedia)
            {
                string text = charSet_enc.decodeText(tempText.ToArray());
                mlBody.Append(text);
            }
            return(bty);
        }
Exemple #20
0
        public void writeTo(TextWriter wr)
        {
            if (mlTo != null)
            {
                wr.WriteLine("{0}: {1}", "To", mlTo.ToString());
            }
            if (mlCC != null)
            {
                wr.WriteLine("{0}: {1}", "CC", mlCC.ToString());
            }
            if (mlFrom != null)
            {
                wr.WriteLine("{0}: {1}", "From", mlFrom.ToString());
            }
            if (mlReturnPath != null)
            {
                wr.WriteLine("{0}: {1}", "ReturnPath", mlReturnPath.ToString());
            }
            if (mlReferences != null)
            {
                wr.WriteLine("{0}: {1}", "References", mlReferences.ToString());
            }
            if (mlInReplyTo != null)
            {
                wr.WriteLine("{0}: {1}", "InReplyTo", mlInReplyTo.ToString());
            }
            if (mlMessageID != null)
            {
                wr.WriteLine("{0}: {1}", "MessageID", mlMessageID.ToString());
            }
            if (mlSubject != null)
            {
                wr.WriteLine("{0}: {1}", "Subject", SubjectEncode.current.encode(mlSubject));
            }
            if (mlDate != null)
            {
                wr.WriteLine("{0}: {1}", "Date", mlDate);
            }
            if (mlContentType != null)
            {
                wr.WriteLine("{0}: {1}", "Content-Type", mlContentType);
            }
            if (mlContentTransferEncoding != null)
            {
                wr.WriteLine("{0}: {1}", "Content-Transfer-Encoding", mlContentTransferEncoding);
            }
            if (mlContentDisposition != null)
            {
                wr.WriteLine("{0}: {1}", "Content-Disposition", mlContentDisposition);
            }
            wr.WriteLine("{0}: {1}", "MIME-Version", "1.0");
            wr.WriteLine("{0}: {1}", "X-Mailer", "HDD LibEML 1.0");

            string          transferEncoding = mlContentTransferEncoding.major;
            TransferEncoder transfer_enc     = transferEnc.getEncoding(transferEncoding);

            string         charSet     = mlContentType.charSet;
            CharsetEncoder charSet_enc = charSetEnc.getEncoding(charSet);

            wr.WriteLine();

            if (mlBody != null)
            {
                byte[] bin = charSet_enc.encodeText(mlBody.ToString());

                if (transfer_enc == null)
                {
                    throw new ArgumentException("不明な変換コード", transferEncoding);
                }

                wr.Write(transfer_enc.encodeBinary(bin));
            }
            else
            {
                if (transfer_enc == null)
                {
                    throw new ArgumentException("不明な変換コード", transferEncoding);
                }

                mlBinary.Position = 0;

                wr.Write(transfer_enc.encodeBinary(mlBinary.ToArray()));
            }
        }
 public OutputStreamWriter(OutputStream arg0, CharsetEncoder arg1)
     : base(ProxyCtor.I)
 {
     Instance.CallConstructor("(Ljava/io/OutputStream;Ljava/nio/charset/CharsetEncoder;)V", arg0, arg1);
 }
Exemple #22
0
 public static Writer newWriter(WritableByteChannel arg0, CharsetEncoder arg1, int arg2)
 {
     return Static.CallMethod<Writer>(typeof(Channels), "newWriter", "(Ljava/nio/channels/WritableByteChannel;Ljava/nio/charset/CharsetEncoder;I)Ljava/io/Writer;", arg0, arg1, arg2);
 }
 internal DefaultBHttpServerConnection(int buffersize, CharsetDecoder chardecoder, CharsetEncoder
                                       charencoder, MessageConstraints constraints) : this(buffersize, buffersize, chardecoder
                                                                                           , charencoder, constraints, null, null, null, null)
 {
 }