urbanairship-core/src/main/java/com/urbanairship/http/Request.java
public Response execute() {
        HttpURLConnection conn = null;

        try {
            conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod(requestMethod);

            if (body != null) {
                conn.setDoOutput(true);
                conn.setRequestProperty("Content-Type", contentType);
            }

            conn.setDoInput(true);
            conn.setUseCaches(false);
            conn.setAllowUserInteraction(false);

            if (ifModifiedSince > 0) {
                conn.setIfModifiedSince(ifModifiedSince);
            }

            for (String key : responseProperties.keySet()) {
                conn.setRequestProperty(key, responseProperties.get(key));
            }

            if (!UAStringUtil.isEmpty(user) && !UAStringUtil.isEmpty(password)) {
                String credentials = user + ":" + password;
                conn.setRequestProperty("Authorization", "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP));
            }

            // Create the form content
            if (body != null) {

                if (compressRequestBody) {
                    conn.setRequestProperty("Content-Encoding", "gzip");
                    OutputStream out = conn.getOutputStream();
                    GZIPOutputStream gos = new GZIPOutputStream(out);
                    Writer writer = new OutputStreamWriter(gos, "UTF-8");
                    writer.write(body);
                    writer.close();
                    gos.close();
                    out.close();
                } else {
                    OutputStream out = conn.getOutputStream();
                    Writer writer = new OutputStreamWriter(out, "UTF-8");
                    writer.write(body);
                    writer.close();
                    out.close();
                }
            }

            Response.Builder responseBuilder = new Response.Builder(conn.getResponseCode())
                    .setResponseMessage(conn.getResponseMessage())
                    .setResponseHeaders(conn.getHeaderFields())
                    .setLastModified(conn.getLastModified());


            try {
                responseBuilder.setResponseBody(readEntireStream(conn.getInputStream()));
            } catch (IOException ex) {
                responseBuilder.setResponseBody(readEntireStream(conn.getErrorStream()));
            }

            return responseBuilder.create();

        } catch (Exception ex) {
            Logger.debug("Request - Request failed URL: " + url + " method: " + requestMethod, ex);
            return null;
        } finally {
            if (conn != null) {
                conn.disconnect();
            }
        }
    }
/**
     * Executes the request.
     *
     * @return The request response.
     */
Executes the request.
@return The request response.
Executes the request . @return The request response .
public Response execute() {
        HttpURLConnection conn = null;
        try {
            conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod(requestMethod);
            if (body != null) {
                conn.setDoOutput(true);
                conn.setRequestProperty("Content-Type", contentType);
            }
            conn.setDoInput(true);
            conn.setUseCaches(false);
            conn.setAllowUserInteraction(false);
            if (ifModifiedSince > 0) {
                conn.setIfModifiedSince(ifModifiedSince);
            }
            for (String key : responseProperties.keySet()) {
                conn.setRequestProperty(key, responseProperties.get(key));
            }
            if (!UAStringUtil.isEmpty(user) && !UAStringUtil.isEmpty(password)) {
                String credentials = user + ":" + password;
                conn.setRequestProperty("Authorization", "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP));
            }
            if (body != null) {
                if (compressRequestBody) {
                    conn.setRequestProperty("Content-Encoding", "gzip");
                    OutputStream out = conn.getOutputStream();
                    GZIPOutputStream gos = new GZIPOutputStream(out);
                    Writer writer = new OutputStreamWriter(gos, "UTF-8");
                    writer.write(body);
                    writer.close();
                    gos.close();
                    out.close();
                } else {
                    OutputStream out = conn.getOutputStream();
                    Writer writer = new OutputStreamWriter(out, "UTF-8");
                    writer.write(body);
                    writer.close();
                    out.close();
                }
            }
            Response.Builder responseBuilder = new Response.Builder(conn.getResponseCode())
                    .setResponseMessage(conn.getResponseMessage())
                    .setResponseHeaders(conn.getHeaderFields())
                    .setLastModified(conn.getLastModified());
            try {
                responseBuilder.setResponseBody(readEntireStream(conn.getInputStream()));
            } catch (IOException ex) {
                responseBuilder.setResponseBody(readEntireStream(conn.getErrorStream()));
            }
            return responseBuilder.create();
        } catch (Exception ex) {
            Logger.debug("Request - Request failed URL: " + url + " method: " + requestMethod, ex);
            return null;
        } finally {
            if (conn != null) {
                conn.disconnect();
            }
        }
    }
public Response execute ( ) { HttpURLConnection conn = null ; try { conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setRequestMethod ( requestMethod ) ; if ( body != null ) { conn . setDoOutput ( true ) ; conn . setRequestProperty ( "Content-Type" , contentType ) ; } conn . setDoInput ( true ) ; conn . setUseCaches ( false ) ; conn . setAllowUserInteraction ( false ) ; if ( ifModifiedSince > 0 ) { conn . setIfModifiedSince ( ifModifiedSince ) ; } for ( String key : responseProperties . keySet ( ) ) { conn . setRequestProperty ( key , responseProperties . get ( key ) ) ; } if ( ! UAStringUtil . isEmpty ( user ) && ! UAStringUtil . isEmpty ( password ) ) { String credentials = user + ":" + password ; conn . setRequestProperty ( "Authorization" , "Basic " + Base64 . encodeToString ( credentials . getBytes ( ) , Base64 . NO_WRAP ) ) ; } if ( body != null ) { if ( compressRequestBody ) { conn . setRequestProperty ( "Content-Encoding" , "gzip" ) ; OutputStream out = conn . getOutputStream ( ) ; GZIPOutputStream gos = new GZIPOutputStream ( out ) ; Writer writer = new OutputStreamWriter ( gos , "UTF-8" ) ; writer . write ( body ) ; writer . close ( ) ; gos . close ( ) ; out . close ( ) ; } else { OutputStream out = conn . getOutputStream ( ) ; Writer writer = new OutputStreamWriter ( out , "UTF-8" ) ; writer . write ( body ) ; writer . close ( ) ; out . close ( ) ; } } Response . Builder responseBuilder = new Response . Builder ( conn . getResponseCode ( ) ) . setResponseMessage ( conn . getResponseMessage ( ) ) . setResponseHeaders ( conn . getHeaderFields ( ) ) . setLastModified ( conn . getLastModified ( ) ) ; try { responseBuilder . setResponseBody ( readEntireStream ( conn . getInputStream ( ) ) ) ; } catch ( IOException ex ) { responseBuilder . setResponseBody ( readEntireStream ( conn . getErrorStream ( ) ) ) ; } return responseBuilder . create ( ) ; } catch ( Exception ex ) { Logger . debug ( "Request - Request failed URL: " + url + " method: " + requestMethod , ex ) ; return null ; } finally { if ( conn != null ) { conn . disconnect ( ) ; } } }
Executes the request.
Executes the request .
// Create the form content