Search in sources :

Example 31 with HttpPatch

use of org.apache.http.client.methods.HttpPatch in project azure-tools-for-java by Microsoft.

the class ADLSGen2FSOperation method appendData.

private Observable<Long> appendData(String filePath, File src) {
    try {
        InputStreamEntity reqEntity = new InputStreamEntity(new FileInputStream(src), -1, ContentType.APPLICATION_OCTET_STREAM);
        BufferedHttpEntity entity = new BufferedHttpEntity(reqEntity);
        long len = entity.getContentLength();
        HttpPatch req = new HttpPatch(filePath);
        http.setContentType("application/octet-stream");
        return http.executeReqAndCheckStatus(req, entity, this.appendReqParams, Collections.emptyList(), 202).map(ignore -> len);
    } catch (FileNotFoundException e) {
        throw new RuntimeException(new IllegalArgumentException("Can not find the aritifact"));
    } catch (IOException e) {
        throw new RuntimeException(new IllegalArgumentException("Can not read the aritfact"));
    }
}
Also used : BufferedHttpEntity(org.apache.http.entity.BufferedHttpEntity) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) HttpPatch(org.apache.http.client.methods.HttpPatch) InputStreamEntity(org.apache.http.entity.InputStreamEntity)

Example 32 with HttpPatch

use of org.apache.http.client.methods.HttpPatch in project azure-tools-for-java by Microsoft.

the class ADLSGen2FSOperation method flushData.

private Observable<Boolean> flushData(String filePath, long flushLen) {
    HttpPatch req = new HttpPatch(filePath);
    List<NameValuePair> flushReqParams = this.flushReqParamsBuilder.setPosition(flushLen).build();
    http.setContentType("application/json");
    return http.executeReqAndCheckStatus(req, null, flushReqParams, Collections.emptyList(), 200).map(ignore -> true);
}
Also used : NameValuePair(org.apache.http.NameValuePair) HttpPatch(org.apache.http.client.methods.HttpPatch)

Example 33 with HttpPatch

use of org.apache.http.client.methods.HttpPatch in project knox by apache.

the class DefaultDispatch method doPatch.

@Override
public void doPatch(URI url, HttpServletRequest request, HttpServletResponse response) throws IOException {
    HttpPatch method = new HttpPatch(url);
    HttpEntity entity = createRequestEntity(request);
    method.setEntity(entity);
    copyRequestHeaderFields(method, request);
    executeRequestWrapper(method, request, response);
}
Also used : HttpEntity(org.apache.http.HttpEntity) HttpPatch(org.apache.http.client.methods.HttpPatch)

Aggregations

HttpPatch (org.apache.http.client.methods.HttpPatch)33 HttpPost (org.apache.http.client.methods.HttpPost)15 HttpPut (org.apache.http.client.methods.HttpPut)15 IOException (java.io.IOException)13 StringEntity (org.apache.http.entity.StringEntity)13 HttpGet (org.apache.http.client.methods.HttpGet)12 HttpDelete (org.apache.http.client.methods.HttpDelete)11 HttpClient (org.apache.http.client.HttpClient)7 HttpHead (org.apache.http.client.methods.HttpHead)7 URI (java.net.URI)6 HttpRequestBase (org.apache.http.client.methods.HttpRequestBase)6 HttpResponse (org.apache.http.HttpResponse)5 InputStreamEntity (org.apache.http.entity.InputStreamEntity)5 URISyntaxException (java.net.URISyntaxException)4 HashMap (java.util.HashMap)4 URL (org.apache.axis2.util.URL)4 HttpEntity (org.apache.http.HttpEntity)4 HttpOptions (org.apache.http.client.methods.HttpOptions)4 HttpTrace (org.apache.http.client.methods.HttpTrace)4 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)4