1 28 29 package HTTPClient; 30 31 import java.io.IOException ; 32 33 41 42 final class ResponseHandler implements GlobalConstants 43 { 44 45 RespInputStream stream; 46 47 48 Response resp; 49 50 51 Request request; 52 53 55 boolean eof = false; 56 57 58 IOException exception = null; 59 60 61 69 ResponseHandler(Response resp, Request request, StreamDemultiplexor demux) 70 { 71 this.resp = resp; 72 this.request = request; 73 this.stream = new RespInputStream(demux, this); 74 75 if (DebugDemux) 76 System.err.println("Demux: Opening stream " + 77 this.stream.hashCode() + " (" + 78 " (" + demux.hashCode() + ") (" + 79 Thread.currentThread() + ")"); 80 } 81 82 83 85 private byte[] endbndry = null; 86 87 88 private int[] end_cmp = null; 89 90 98 byte[] getEndBoundary(ExtBufferedInputStream MasterStream) 99 throws IOException , ParseException 100 { 101 if (endbndry == null) 102 setupBoundary(MasterStream); 103 104 return endbndry; 105 } 106 107 115 int[] getEndCompiled(ExtBufferedInputStream MasterStream) 116 throws IOException , ParseException 117 { 118 if (end_cmp == null) 119 setupBoundary(MasterStream); 120 121 return end_cmp; 122 } 123 124 128 void setupBoundary(ExtBufferedInputStream MasterStream) 129 throws IOException , ParseException 130 { 131 String endstr = "--" + Util.getParameter("boundary", 132 resp.getHeader("Content-Type")) + 133 "--\r\n"; 134 endbndry = new byte[endstr.length()]; 135 endstr.getBytes(0, endbndry.length, endbndry, 0); 136 end_cmp = Util.compile_search(endbndry); 137 MasterStream.initMark(); 138 } 139 } 140 141 | Popular Tags |