Examples of HTTPException


Examples of com.robustaweb.library.commons.exception.HttpException

                URL u;
                try {
                    u = new URL(url);
                } catch (MalformedURLException ex) {
                    throw new HttpException("malformedURI", ex);
                }

                try {
                    if (AsynchronousRestClientSun.proxy != null) {
                        http = (HttpURLConnection) u.openConnection(AsynchronousRestClientSun.proxy);
                    } else {
                        http = (HttpURLConnection) u.openConnection();
                    }
                    http.addRequestProperty("Content-type", contentType);
                    if (authorizationValue != null) {
                        http.addRequestProperty("Authorization", AsynchronousRestClientSun.authorizationValue);
                    }
                    http.setRequestMethod(method.toString());
                    http.setDoInput(true);
                    switch (method) {
                        case PUT:
                        case POST:
                            http.setDoOutput(true);
                            /* if there is something to put in the requestBody*/
                            if (requestBody != null && requestBody.length() >= 0) {
                                DataOutputStream wr = new DataOutputStream(http.getOutputStream());
                                wr.writeBytes(requestBody);
                                wr.flush();
                                wr.close();
                            }
                            break;
                    }
                    response = FileUtils.readInputStream(http.getInputStream());

                    //handling the callback
                    callCallback(callback, httpCode, response);

                } catch (IOException ex) {
                    ex.printStackTrace();
                    throw new HttpException(ex.getMessage(), ex);
                } finally {
                    clean();
                }
            }
        };
View Full Code Here

Examples of com.robustaweb.library.commons.exception.HttpException

    @Override
    public void join() {
        try {
            requestThread.join();
        } catch (InterruptedException ex) {
            throw new HttpException("Can't join the client's thread : " + ex.getMessage(), ex);
        }
    }
View Full Code Here

Examples of com.robustaweb.library.commons.exception.HttpException

        URL u;
        try {
            u = new URL(url);
        } catch (MalformedURLException ex) {
            throw new HttpException("malformedURI", ex);
        }

        try {

           
            if (SunRestClient.proxy != null){
                http = (HttpURLConnection) u.openConnection(SunRestClient.proxy);
            }else{
                http = (HttpURLConnection) u.openConnection();
            }
            

            http.addRequestProperty("Content-type", this.contentType);
            if (authorizationValue != null) {
                http.addRequestProperty("Authorization", SunRestClient.authorizationValue);
            }

            http.setRequestMethod(method.toString());
            http.setDoInput(true);
            switch (method) {
                case PUT:
                case POST:
                    http.setDoOutput(true);
                    /* if there is something to put in the requestBody*/
                    if (this.requestBody != null && this.requestBody.length() >= 0) {
                        DataOutputStream wr = new DataOutputStream(http.getOutputStream());
                        wr.writeBytes(requestBody);
                        wr.flush();
                        wr.close();
                    }
                    break;
            }
            this.response = FileUtils.readInputStream(http.getInputStream());
            this.responseHeaders = readHeaders(http);
           
           
          
            return this.response;
        } catch (IOException ex) {
            ex.printStackTrace();
            throw new HttpException(ex.getMessage(), ex);
        } finally {
            clean();
        }       
    }
View Full Code Here

Examples of com.robustaweb.library.commons.exception.HttpException

         * @{@inheritDoc }
         */
        @Override
        public void onError(Request request, Throwable exception) {
            System.out.println("error:"+exception.getMessage());
            callback.onException(new HttpException("Unable to execute request : " + exception.getMessage(), exception));
        }
View Full Code Here

Examples of com.robustaweb.library.commons.exception.HttpException

  @Override
  public void join() {
    try {
      requestThread.join();
    } catch (InterruptedException ex) {
      throw new HttpException("Can't join the client's thread : "
          + ex.getMessage(), ex);
    }
  }
View Full Code Here

Examples of com.robustaweb.library.commons.exception.HttpException

            //Special case of forms && POST/PUT methods
            if (contentTypeIsForm() && (method == HttpMethod.POST || method == HttpMethod.PUT)) {
                //params will go in the requestBody
                if (requestBody != null && requestBody.length() > 0) {
                    throw new HttpException("Can't do a POST or PUT method with both parameters with 'x-www-form-urlencoded', and a non-null requestBody");
                } else {
                    //adding parameters to the requestBody
                    assert requestBody == null || requestBody.length() == 0;
                    body = encodeFormRequestBody(parameters);
                }
View Full Code Here

Examples of com.robustaweb.library.commons.exception.HttpException

           
           
            return this.response;

        } catch (IOException ex) {
            throw new HttpException("IO Exception : "+ex.getMessage(), ex);
        }finally{
            clear();
        }
    }
View Full Code Here

Examples of com.volantis.xml.pipeline.sax.drivers.web.HTTPException

            this.url, requestParameters, target);
        final URL keyUrl;
        try {
            keyUrl = new URL(url);
        } catch (MalformedURLException e) {
            throw new HTTPException("Invalid URL: " + url, e);
        }
        if (respAccessor == null) {
            executor = target.createHTTPRequestExecutor(
                    this.url, requestType, version, proxyManager, xmlPipelineContext);
            transferMetaData(executor);
View Full Code Here

Examples of com.vtence.molecule.HttpException

        assertScoping("on");
    }

    @Test public void
    gracefullyClosesConnectionAndRemovesFromScopeWhenAnErrorOccurs() throws Exception {
        connectionScope.connectTo(crashWith(new HttpException("Boom!")));

        try {
            connectionScope.handle(request, response);
            fail("HttpException did not bubble up");
        } catch (HttpException expected) {
View Full Code Here

Examples of dijjer.io.xfer.http.HTTPException

      return response;
    } catch (Exception e) {
      try {
        return new HTTPExceptionResponse(e);
      } catch (IOException ex) {
        throw new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR, "Internal Error", ex.getMessage());
      }
    }
  }
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.