List of usage examples for org.apache.http.client.methods HttpPut HttpPut
public HttpPut(final String uri)
From source file:de.devbliss.apitester.factory.impl.DefaultPutFactory.java
public HttpPut createPutRequest(URI uri, Object payload) throws IOException { HttpPut request = new HttpPut(uri); if (payload != null) { request.setEntity(entityBuilder.buildEntity(payload)); }//ww w. j a v a 2 s .c o m return request; }
From source file:com.magnet.plugin.api.requests.PutRequest.java
@Override protected HttpRequestBase getRequest(RequestModel requestModel) { HttpPut httpPost = new HttpPut(requestModel.getTestUrl()); try {//from w w w . jav a 2 s. c o m httpPost.setEntity(new StringEntity(requestModel.getRequest(), "UTF-8")); } catch (Exception e) { } return httpPost; }
From source file:tech.beshu.ror.integration.IndicesReverseWildcardTests.java
private static void insertDoc(String docName, RestClient restClient) { if (adminClient == null) { adminClient = restClient;/* w w w .ja v a 2s . c om*/ } try { HttpPut request = new HttpPut(restClient.from("/logstash-" + docName + "/documents/doc-" + docName)); request.setHeader("refresh", "true"); request.setHeader("timeout", "50s"); request.setHeader("Content-Type", "application/json"); request.setEntity(new StringEntity("{\"title\": \"" + docName + "\"}")); System.out.println(body(restClient.execute(request))); } catch (Exception e) { e.printStackTrace(); throw new IllegalStateException("Test problem", e); } // Polling phase.. #TODO is there a better way? try { HttpResponse response; do { Thread.sleep(200); HttpHead request = new HttpHead( restClient.from("/logstash-" + docName + "/documents/doc-" + docName)); response = restClient.execute(request); System.out.println( "polling for " + docName + ".. result: " + response.getStatusLine().getReasonPhrase()); } while (response.getStatusLine().getStatusCode() != 200); } catch (Exception e) { e.printStackTrace(); throw new IllegalStateException("Cannot configure test case", e); } }
From source file:com.deployd.Deployd.java
public static JSONObject put(JSONObject input, String uri) throws ClientProtocolException, IOException, JSONException { HttpPut post = new HttpPut(endpoint + uri); HttpClient client = new DefaultHttpClient(); post.setEntity(new ByteArrayEntity(input.toString().getBytes("UTF8"))); HttpResponse response = client.execute(post); ByteArrayEntity e = (ByteArrayEntity) response.getEntity(); InputStream is = e.getContent(); String data = new Scanner(is).next(); JSONObject result = new JSONObject(data); return result; }
From source file:org.gradle.internal.resource.transport.http.HttpResourceUploader.java
public void upload(Factory<InputStream> source, Long contentLength, URI destination) throws IOException { HttpPut method = new HttpPut(destination); final RepeatableInputStreamEntity entity = new RepeatableInputStreamEntity(source, contentLength, ContentType.APPLICATION_OCTET_STREAM); method.setEntity(entity);//from w w w . j a v a 2s .co m HttpResponse response = http.performHttpRequest(method); EntityUtils.consume(response.getEntity()); if (!http.wasSuccessful(response)) { throw new IOException( String.format("Could not PUT '%s'. Received status code %s from server: %s", destination, response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase())); } }
From source file:com.jaeksoft.searchlib.remote.UriWriteObject.java
public UriWriteObject(URI uri, Externalizable object) throws IOException { HttpPut httpPut = new HttpPut(uri.toASCIIString()); httpPut.setConfig(requestConfig);/*from www. j a va 2s . c o m*/ ByteArrayOutputStream baos = new ByteArrayOutputStream(); swo = new StreamWriteObject(baos); swo.write(object); swo.close(true); swo = null; sro = null; httpPut.setEntity(new ByteArrayEntity(baos.toByteArray())); execute(httpPut); }
From source file:es.ugr.swad.swadroid.webservices.RestEasy.java
public static HttpResponse doPut(String url, JSONObject c) throws ClientProtocolException, IOException { HttpClient httpclient = new DefaultHttpClient(); HttpPut request = new HttpPut(url); StringEntity s = new StringEntity(c.toString()); s.setContentEncoding("UTF-8"); s.setContentType("application/json"); request.setEntity(s);//from ww w. j av a 2 s.com request.addHeader("accept", "application/json"); return httpclient.execute(request); }
From source file:com.strato.hidrive.api.connection.httpgateway.request.PutRequest.java
protected HttpRequestBase createHttpRequest(String requestUri, HttpRequestParamsVisitor<?> visitor) throws UnsupportedEncodingException { return new HttpPut(requestUri + visitor.getHttpRequestParams()); }
From source file:com.servoy.extensions.plugins.http.PutRequest.java
public PutRequest(String url, DefaultHttpClient hc, IClientPluginAccess plugin) { super(url, hc, new HttpPut(url), plugin); }
From source file:tech.beshu.ror.integration.FieldLevelSecurityTests.java
private static void insertDoc(String docName, RestClient restClient, String idx, String field) { if (adminClient == null) { adminClient = restClient;//from w w w . j ava2 s. c o m } String path = "/" + IDX_PREFIX + idx + "/documents/doc-" + docName + String.valueOf(Math.random()); try { HttpPut request = new HttpPut(restClient.from(path)); request.setHeader("Content-Type", "application/json"); request.setHeader("refresh", "true"); request.setHeader("timeout", "50s"); String body = "{\"" + field + "\": \"" + docName + "\", \"dummy2\": true}"; System.out.println("inserting: " + body); request.setEntity(new StringEntity(body)); System.out.println(body(restClient.execute(request))); } catch (Exception e) { e.printStackTrace(); throw new IllegalStateException("Test problem", e); } // Polling phase.. #TODO is there a better way? try { Thread.sleep(5000); HttpResponse response; do { HttpHead request = new HttpHead(restClient.from(path)); request.setHeader("x-api-key", "p"); response = restClient.execute(request); System.out.println( "polling for " + docName + ".. result: " + response.getStatusLine().getReasonPhrase()); Thread.sleep(200); } while (response.getStatusLine().getStatusCode() != 200); } catch (Exception e) { e.printStackTrace(); throw new IllegalStateException("Cannot configure test case", e); } }