List of usage examples for org.apache.commons.httpclient.methods PutMethod setRequestContentLength
public void setRequestContentLength(int paramInt)
From source file:org.apache.maven.wagon.providers.webdav.CorrectedWebdavResource.java
/** * Execute the PUT method for the given path. * * @param path the server relative path to put the data * @param inputStream The input stream./*from ww w. j av a 2 s . c o m*/ * * @return true if the method is succeeded. */ public boolean putMethod(String path, InputStream inputStream, int contentLength) throws IOException { setClient(); PutMethod method = new PutMethod(URIUtil.encodePathQuery(path)); method.setFollowRedirects(super.followRedirects); generateIfHeader(method); if (getGetContentType() != null && !getGetContentType().equals("")) { method.setRequestHeader("Content-Type", getGetContentType()); } method.setRequestContentLength(contentLength); method.setRequestBody(inputStream); generateTransactionHeader(method); generateAdditionalHeaders(method); int statusCode = client.executeMethod(method); setStatusCode(statusCode); return isHttpSuccess(statusCode); }
From source file:org.apache.webdav.lib.WebdavResource.java
/** * Execute the PUT method for the given path. * * @param path the server relative path to put the data * @param is The input stream.//from w w w .j a v a 2s . c o m * @return true if the method is succeeded. * @exception HttpException * @exception IOException */ public boolean putMethod(String path, InputStream is) throws HttpException, IOException { setClient(); PutMethod method = new PutMethod(URIUtil.encodePathQuery(path)); generateIfHeader(method); if (getGetContentType() != null && !getGetContentType().equals("")) method.setRequestHeader("Content-Type", getGetContentType()); method.setRequestContentLength(PutMethod.CONTENT_LENGTH_CHUNKED); method.setRequestBody(is); generateTransactionHeader(method); generateAdditionalHeaders(method); int statusCode = client.executeMethod(method); setStatusCode(statusCode); return (statusCode >= 200 && statusCode < 300) ? true : false; }
From source file:org.apache.webdav.lib.WebdavResource.java
/** * Execute the PUT method for the given path. * * @param path the server relative path to put the given file * @param file the filename to get on local. * @return true if the method is succeeded. * @exception HttpException/*w ww . j a va 2 s .com*/ * @exception IOException */ public boolean putMethod(String path, File file) throws HttpException, IOException { setClient(); PutMethod method = new PutMethod(URIUtil.encodePathQuery(path)); generateIfHeader(method); if (getGetContentType() != null && !getGetContentType().equals("")) method.setRequestHeader("Content-Type", getGetContentType()); long fileLength = file.length(); method.setRequestContentLength( fileLength <= Integer.MAX_VALUE ? (int) fileLength : PutMethod.CONTENT_LENGTH_CHUNKED); method.setRequestBody(new FileInputStream(file)); generateTransactionHeader(method); generateAdditionalHeaders(method); int statusCode = client.executeMethod(method); setStatusCode(statusCode); return (statusCode >= 200 && statusCode < 300) ? true : false; }
From source file:org.pengyou.client.lib.DavResource.java
/** * Execute the PUT method for the given path. * * @param path the server relative path to put the data * @param is The input stream.//w w w . ja v a 2 s . com * @return true if the method is succeeded. * @exception HttpException * @exception IOException */ protected boolean putMethod() throws HttpException, IOException { log.debug("putMethod"); InputStream is = new ByteArrayInputStream(this.contentBody); HttpClient client = getSessionInstance(); PutMethod method = new PutMethod(context.getBaseUrl() + path); generateIfHeader(method); if (getContentType() != null && !getContentType().equals("")) method.setRequestHeader("Content-Type", getContentType()); method.setRequestContentLength(PutMethod.CONTENT_LENGTH_CHUNKED); method.setRequestBody(is); generateTransactionHeader(method); int statusCode = client.executeMethod(method); this.statusCode = statusCode; return (statusCode >= 200 && statusCode < 300) ? true : false; }