1 16 17 package org.apache.coyote.tomcat3; 18 19 import java.io.IOException ; 20 import java.util.Locale ; 21 22 import org.apache.coyote.ActionCode; 23 import org.apache.tomcat.core.Response; 24 import org.apache.tomcat.util.buf.ByteChunk; 25 26 30 31 class Tomcat3Response extends Response { 32 String reportedname=null; 33 34 org.apache.coyote.Response coyoteResponse=null; 35 36 ByteChunk outputChunk = new ByteChunk(); 37 38 boolean acknowledged=false; 39 40 public Tomcat3Response() { 41 super(); 42 } 43 44 46 public void setCoyoteResponse(org.apache.coyote.Response cRes) { 47 coyoteResponse = cRes; 48 headers = coyoteResponse.getMimeHeaders(); 49 } 50 51 public void init() { 52 super.init(); 53 } 54 55 public void recycle() { 56 super.recycle(); 57 if(coyoteResponse != null) coyoteResponse.recycle(); 58 outputChunk.recycle(); 59 acknowledged=false; 60 } 61 62 public void setReported(String reported) { 64 reportedname = reported; 65 } 66 67 public void endHeaders() throws IOException { 68 super.endHeaders(); 69 coyoteResponse.setStatus(getStatus()); 70 int cLen = getContentLength(); 72 if( cLen >= 0 ) { 73 coyoteResponse.setContentLength(cLen); 74 } 75 coyoteResponse.sendHeaders(); 77 } 78 79 public void clientFlush() throws IOException { 80 coyoteResponse.action( ActionCode.ACTION_CLIENT_FLUSH, coyoteResponse ); 81 } 82 83 public void doWrite( byte buffer[], int pos, int count) 84 throws IOException 85 { 86 if( count > 0 ) { 87 outputChunk.setBytes(buffer, pos, count); 89 coyoteResponse.doWrite( outputChunk ); 90 } 91 } 92 93 public void reset() throws IllegalStateException { 94 super.reset(); 95 if( ! included ) 96 coyoteResponse.reset(); 97 } 98 99 public void finish() throws IOException { 100 super.finish(); 101 coyoteResponse.finish(); 102 } 103 104 109 public void sendAcknowledgement() 110 throws IOException { 111 112 if( status >= 300 ) acknowledged = true; 114 if(acknowledged) 116 return; 117 if (isIncluded()) 119 return; 120 if (isBufferCommitted()) 121 throw new IllegalStateException 122 (sm.getString("hsrf.error.ise")); 123 124 coyoteResponse.acknowledge(); 125 acknowledged=true; 126 } 127 128 public void setLocale(Locale locale) { 129 if (locale == null || included) { 130 return; } 132 this.locale = locale; 133 coyoteResponse.setLocale(locale); 134 contentLanguage = coyoteResponse.getContentLanguage(); 135 headers.setValue("Content-Language").setString(contentLanguage); 138 } 139 140 public void setContentType(String contentType) { 141 if (included) { 142 return; 143 } 144 coyoteResponse.setContentType(contentType); 145 this.contentType = coyoteResponse.getContentType(); 146 this.characterEncoding = coyoteResponse.getCharacterEncoding(); 147 this.haveCharacterEncoding = true; 148 headers.setValue("Content-Type").setString(contentType); 150 } 151 152 } 153 | Popular Tags |