1 29 30 package com.caucho.quercus.lib.curl; 31 32 import com.caucho.quercus.env.BinaryValue; 33 import com.caucho.quercus.env.Env; 34 35 import java.io.IOException ; 36 import java.io.OutputStream ; 37 import java.net.ProtocolException ; 38 39 42 public class HttpPostRequest 43 extends HttpRequest 44 { 45 public HttpPostRequest(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 BinaryValue body = getCurlResource().getPostBody(); 69 70 if (body == null) 71 return; 72 73 HttpConnection conn = getHttpConnection(); 74 OutputStream out = conn.getOutputStream(); 75 76 int length = body.length(); 77 78 for (int i = 0; i < length; i++) { 79 out.write((byte)body.charAt(i)); 80 } 81 82 out.close(); 83 } 84 } 85 | Popular Tags |