1 29 30 package com.caucho.quercus.lib.curl; 31 32 import com.caucho.quercus.env.Env; 33 import com.caucho.quercus.lib.file.BinaryInput; 34 35 import java.io.IOException ; 36 import java.io.OutputStream ; 37 import java.net.ProtocolException ; 38 39 42 public class HttpPutRequest 43 extends HttpRequest 44 { 45 public HttpPutRequest(CurlResource curlResource) 46 { 47 super(curlResource); 48 } 49 50 53 protected void init(Env env) 54 throws ProtocolException 55 { 56 super.init(env); 57 getHttpConnection().setDoOutput(true); 58 } 59 60 63 protected void transfer(Env env) 64 throws IOException 65 { 66 super.transfer(env); 67 68 HttpConnection conn = getHttpConnection(); 69 OutputStream out = conn.getOutputStream(); 70 71 CurlResource curl = getCurlResource(); 72 73 BinaryInput in = curl.getUploadFile(); 74 int length = curl.getUploadFileSize(); 75 76 for (int i = 0; i < length; i++) { 77 int ch = in.read(); 78 79 if (ch < 0) 80 break; 81 82 out.write(ch); 83 } 84 85 out.close(); 86 } 87 } 88 | Popular Tags |