Package org.apache.tomcat.util.buf

Examples of org.apache.tomcat.util.buf.C2BConverter


  gotEnc=true;
  if(enc==null) enc=DEFAULT_ENCODING;
  conv=(C2BConverter)encoders.get(enc);
  if(conv==null) {
      try {
    conv=new C2BConverter(bb,enc);
    encoders.put(enc, conv);
      } catch(IOException ex ) {
    conv=(C2BConverter)encoders.get(DEFAULT_ENCODING);
    if(conv==null) {
        try {
      conv=new C2BConverter(bb, DEFAULT_ENCODING);
      encoders.put(DEFAULT_ENCODING, conv);
        } catch( IOException e ) {}
    }
      }
  }
View Full Code Here


                    conv = AccessController.doPrivileged(
                            new PrivilegedExceptionAction<C2BConverter>(){

                                @Override
                                public C2BConverter run() throws IOException{
                                    return new C2BConverter(bb, enc);
                                }

                            }
                    );
                }catch(PrivilegedActionException ex){
                    Exception e = ex.getException();
                    if (e instanceof IOException) {
                        throw (IOException)e;
                    }
                }
            } else {
                conv = new C2BConverter(bb, enc);
            }

            encoders.put(enc, conv);

        }
View Full Code Here

        if (enc == null)
            enc = DEFAULT_ENCODING;
        conv = (C2BConverter) encoders.get(enc);
        if (conv == null) {
            try {
                conv = new C2BConverter(bb, enc);
                encoders.put(enc, conv);
            } catch (IOException e) {
                conv = (C2BConverter) encoders.get(DEFAULT_ENCODING);
                if (conv == null) {
                    try {
                        conv = new C2BConverter(bb, DEFAULT_ENCODING);
                        encoders.put(DEFAULT_ENCODING, conv);
                    } catch (IOException ex) {
                        // Ignore
                    }
                }
View Full Code Here

        if (enc == null)
            enc = DEFAULT_ENCODING;
        conv = (C2BConverter) encoders.get(enc);
        if (conv == null) {
            try {
                conv = new C2BConverter(bb, enc);
                encoders.put(enc, conv);
            } catch (IOException e) {
                conv = (C2BConverter) encoders.get(DEFAULT_ENCODING);
                if (conv == null) {
                    try {
                        conv = new C2BConverter(bb, DEFAULT_ENCODING);
                        encoders.put(DEFAULT_ENCODING, conv);
                    } catch (IOException ex) {
                        // Ignore
                    }
                }
View Full Code Here

    public void appendHead(Response res) throws IOException {
        if( log.isDebugEnabled() )
            log.debug("COMMIT sending headers " + res + " " + res.getMimeHeaders() );
       
        C2BConverter c2b=mc.getConverter();
       
        outputMsg.reset();
        outputMsg.appendByte(AjpConstants.JK_AJP13_SEND_HEADERS);
        outputMsg.appendInt( res.getStatus() );
       
        String message = null;
        if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER) {
            message = res.getMessage();
        }
        if( message==null ){
            message= HttpMessages.getMessage(res.getStatus());
        } else {
            message = message.replace('\n', ' ').replace('\r', ' ');
        }
        tempMB.setString( message );
        c2b.convert( tempMB );
        outputMsg.appendBytes(tempMB);

        // XXX add headers
       
        MimeHeaders headers=res.getMimeHeaders();
        String contentType = res.getContentType();
        if( contentType != null ) {
            headers.setValue("Content-Type").setString(contentType);
        }
        String contentLanguage = res.getContentLanguage();
        if( contentLanguage != null ) {
            headers.setValue("Content-Language").setString(contentLanguage);
        }
        long contentLength = res.getContentLengthLong();
        if( contentLength >= 0 ) {
            headers.setValue("Content-Length").setLong(contentLength);
        }
        int numHeaders = headers.size();
        outputMsg.appendInt(numHeaders);
        for( int i=0; i<numHeaders; i++ ) {
            MessageBytes hN=headers.getName(i);
            // no header to sc conversion - there's little benefit
            // on this direction
            c2b.convert ( hN );
            outputMsg.appendBytes( hN );
                       
            MessageBytes hV=headers.getValue(i);
            c2b.convert( hV );
            outputMsg.appendBytes( hV );
        }
        mc.getSource().send( outputMsg, mc );
    }
View Full Code Here

                try{
                    conv = (C2BConverter)AccessController.doPrivileged(
                            new PrivilegedExceptionAction(){

                                public Object run() throws IOException{
                                    return new C2BConverter(bb, enc);
                                }

                            }
                    );             
                }catch(PrivilegedActionException ex){
                    Exception e = ex.getException();
                    if (e instanceof IOException)
                        throw (IOException)e;
                   
                    if (debug > 0)
                        log("setConverter: " + ex.getMessage());
                }
            } else {
                conv = new C2BConverter(bb, enc);
            }
           
            encoders.put(enc, conv);

        }
View Full Code Here

        }

        private void sendMessage(String message, boolean finalFragment)
                throws IOException {
            ByteChunk bc = new ByteChunk(8192);
            C2BConverter c2b = new C2BConverter(bc, "UTF-8");
            c2b.convert(message);
            c2b.flushBuffer();

            int len = bc.getLength();
            assertTrue(len < 126);

            byte first;
View Full Code Here

                try{
                    conv = (C2BConverter)AccessController.doPrivileged(
                            new PrivilegedExceptionAction(){

                                public Object run() throws IOException{
                                    return new C2BConverter(bb, enc);
                                }

                            }
                    );             
                }catch(PrivilegedActionException ex){
                    Exception e = ex.getException();
                    if (e instanceof IOException)
                        throw (IOException)e;
                }
            } else {
                conv = new C2BConverter(bb, enc);
            }
           
            encoders.put(enc, conv);

        }
View Full Code Here

    public void appendHead(Response res) throws IOException {
        if( log.isDebugEnabled() )
            log.debug("COMMIT sending headers " + res + " " + res.getMimeHeaders() );
       
        C2BConverter c2b=mc.getConverter();
       
        outputMsg.reset();
        outputMsg.appendByte(AjpConstants.JK_AJP13_SEND_HEADERS);
        outputMsg.appendInt( res.getStatus() );
       
        String message = null;
        if (AjpConstants.USE_CUSTOM_STATUS_MSG_IN_HEADER &&
                HttpMessages.isSafeInHttpHeader(res.getMessage())) {
            message = res.getMessage();
        }
        if (message == null) {
            message= HttpMessages.getMessage(res.getStatus());
        }
        if (message == null) {
            // mod_jk + httpd 2.x fails with a null status message - bug 45026
            message = Integer.toString(res.getStatus());
        }
        tempMB.setString( message );
        c2b.convert( tempMB );
        outputMsg.appendBytes(tempMB);

        // XXX add headers
       
        MimeHeaders headers=res.getMimeHeaders();
View Full Code Here

    public void appendHead(Response res) throws IOException {
        if( log.isDebugEnabled() )
            log.debug("COMMIT sending headers " + res + " " + res.getMimeHeaders() );
       
        C2BConverter c2b=mc.getConverter();
       
        outputMsg.reset();
        outputMsg.appendByte(AjpConstants.JK_AJP13_SEND_HEADERS);
        outputMsg.appendInt( res.getStatus() );
       
        String message = null;
        if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER) {
            message = res.getMessage();
        }
        if( message==null ){
            message= HttpMessages.getMessage(res.getStatus());
        } else {
            message = message.replace('\n', ' ').replace('\r', ' ');
        }
        tempMB.setString( message );
        c2b.convert( tempMB );
        outputMsg.appendBytes(tempMB);

        // XXX add headers
       
        MimeHeaders headers=res.getMimeHeaders();
        String contentType = res.getContentType();
        if( contentType != null ) {
            headers.setValue("Content-Type").setString(contentType);
        }
        String contentLanguage = res.getContentLanguage();
        if( contentLanguage != null ) {
            headers.setValue("Content-Language").setString(contentLanguage);
        }
        long contentLength = res.getContentLengthLong();
        if( contentLength >= 0 ) {
            headers.setValue("Content-Length").setLong(contentLength);
        }
        int numHeaders = headers.size();
        outputMsg.appendInt(numHeaders);
        for( int i=0; i<numHeaders; i++ ) {
            MessageBytes hN=headers.getName(i);
            // no header to sc conversion - there's little benefit
            // on this direction
            c2b.convert ( hN );
            outputMsg.appendBytes( hN );
                       
            MessageBytes hV=headers.getValue(i);
            c2b.convert( hV );
            outputMsg.appendBytes( hV );
        }
        mc.getSource().send( outputMsg, mc );
    }
View Full Code Here

TOP

Related Classes of org.apache.tomcat.util.buf.C2BConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.