Package org.apache.commons.httpclient.methods

Examples of org.apache.commons.httpclient.methods.PutMethod.addRequestHeader()


      // Content-Length: nnn
      // ...binary data...
        PutMethod put = new PutMethod( providerURI + "/" + mediaId );
        put.addRequestHeader( "Content-Type", "image/jpg" );
        put.addRequestHeader( "Title", "Title " + receiptName + "" );
        put.addRequestHeader( "Slug", "Slug " + receiptName + "" );
        put.setRequestEntity(
          new InputStreamRequestEntity( new FileInputStream( input ), "image/jpg" ) );
   
        // Get HTTP client
        HttpClient httpclient = new HttpClient();
View Full Code Here


      // Host: media.example.org
      // Content-Type: image/png
      // Content-Length: nnn
      // ...binary data...
        PutMethod put = new PutMethod( providerURI + "/" + mediaId + "-bogus" ); // Does not exist.
        put.addRequestHeader( "Content-Type", "image/jpg" );
        put.addRequestHeader( "Title", "Title " + receiptName + "" );
        put.addRequestHeader( "Slug", "Slug " + receiptName + "" );
        put.setRequestEntity(
          new InputStreamRequestEntity( new FileInputStream( input ), "image/jpg" ) );
   
View Full Code Here

      // Content-Type: image/png
      // Content-Length: nnn
      // ...binary data...
        PutMethod put = new PutMethod( providerURI + "/" + mediaId + "-bogus" ); // Does not exist.
        put.addRequestHeader( "Content-Type", "image/jpg" );
        put.addRequestHeader( "Title", "Title " + receiptName + "" );
        put.addRequestHeader( "Slug", "Slug " + receiptName + "" );
        put.setRequestEntity(
          new InputStreamRequestEntity( new FileInputStream( input ), "image/jpg" ) );
   
        // Get HTTP client
View Full Code Here

      // Content-Length: nnn
      // ...binary data...
        PutMethod put = new PutMethod( providerURI + "/" + mediaId + "-bogus" ); // Does not exist.
        put.addRequestHeader( "Content-Type", "image/jpg" );
        put.addRequestHeader( "Title", "Title " + receiptName + "" );
        put.addRequestHeader( "Slug", "Slug " + receiptName + "" );
        put.setRequestEntity(
          new InputStreamRequestEntity( new FileInputStream( input ), "image/jpg" ) );
   
        // Get HTTP client
        HttpClient httpclient = new HttpClient();
View Full Code Here

    //Workaround: remote method UPDATE dosn't support API-Keys, we need a session
    String token = getAuthenticityToken(monitor);
   
    PutMethod method = new PutMethod(String.format(URL_UPDATE_ISSUE, issueId));
    method.setRequestEntity(requestEntity);
    method.addRequestHeader(HEADER_CSRF_TOKEN, token);
   
    Object response = executeMethod(method, submitIssueParser, monitor, HttpStatus.SC_OK, HttpStatus.SC_UNPROCESSABLE_ENTITY);
   
    if(response instanceof SubmitError) {
      SubmitError error = (SubmitError)response;
View Full Code Here

        return status;
      }

      URI targetURI = URIUtil.toURI(target.getUrl());
      PutMethod uploadMethod = new PutMethod(targetURI.resolve("/v2/apps/" + getApplication().getGuid() + "/bits?async=true").toString());
      uploadMethod.addRequestHeader(new Header("Authorization", "bearer " + target.getCloud().getAccessToken().getString("access_token")));

      Part[] parts = {new StringPart(CFProtocolConstants.V2_KEY_RESOURCES, "[]"), new FilePart(CFProtocolConstants.V2_KEY_APPLICATION, appPackage)};
      uploadMethod.setRequestEntity(new MultipartRequestEntity(parts, uploadMethod.getParams()));

      /* send request */
 
View Full Code Here

     */
    public void test406WhenResourceMethodDoesNotProduceResponseEntityType() throws Exception {
        PutMethod putMethod = new PutMethod(getBaseURI() + "/targeting/resourcewithmethod");

        try {
            putMethod.addRequestHeader("Accept", "text/plain");
            putMethod.setRequestEntity(new StringRequestEntity("some content", "text/plain",
                                                               "UTF-8"));
            client.executeMethod(putMethod);

            assertEquals(200, putMethod.getStatusCode());
View Full Code Here

            putMethod.releaseConnection();
        }

        putMethod = new PutMethod(getBaseURI() + "/targeting/resourcewithmethod");
        try {
            putMethod.addRequestHeader("Accept", "text/customplain");
            putMethod.setRequestEntity(new StringRequestEntity("some content", "text/plain",
                                                               "UTF-8"));
            client.executeMethod(putMethod);

            assertEquals(406, putMethod.getStatusCode());
View Full Code Here

    protected PutMethod executePutXml(String uri, Object object) throws Exception
    {
        HttpClient httpClient = new HttpClient();

        PutMethod putMethod = new PutMethod(uri);
        putMethod.addRequestHeader("Accept", MediaType.APPLICATION_XML.toString());

        StringWriter writer = new StringWriter();
        marshaller.marshal(object, writer);

        RequestEntity entity =
View Full Code Here

        HttpClient httpClient = new HttpClient();
        httpClient.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password));
        httpClient.getParams().setAuthenticationPreemptive(true);

        PutMethod putMethod = new PutMethod(uri);
        putMethod.addRequestHeader("Accept", MediaType.APPLICATION_XML.toString());

        StringWriter writer = new StringWriter();
        marshaller.marshal(object, writer);

        RequestEntity entity =
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.