src/main/java/com/instructure/canvasapi/api/compatibility_synchronous/HttpHelpers.java
/**
     * httpPut is a bare-bones implementation for writing HTTPPut requests to the CanvasAPI.
     * It is used for the old-style synchronous calls that haven't yet been converted.
     * @param putURL
     * @param context
     * @return
     */
httpPut is a bare-bones implementation for writing HTTPPut requests to the CanvasAPI.
It is used for the old-style synchronous calls that haven't yet been converted.
@param putURL
@param context
@return
httpPut is a bare - bones implementation for writing HTTPPut requests to the CanvasAPI . It is used for the old - style synchronous calls that haven ' t yet been converted . @param putURL @param context @return
public static APIHttpResponse httpPut(String putURL, Context context) {
        if(context == null) {
            return new APIHttpResponse();
        }
        try {
            putURL = Masquerading.addMasqueradeId(putURL, context);
            putURL = putURL.replace(" ", "%20");
            String api_protocol = APIHelpers.loadProtocol(context);
            if(!putURL.startsWith("https://") && !putURL.startsWith("http://"))
            {
                putURL = api_protocol + "://"+APIHelpers.getDomain(context)+"/"+putURL;
            }
            HttpPut get = new HttpPut(putURL);
            String token = APIHelpers.getToken(context);
            if(token != null)
            {
                String headerValue = String.format("Bearer %s", token);
                get.addHeader("Authorization",headerValue);
            }
            HttpClient client = getHttpClient(context);
            HttpResponse response = client.execute(get);
            return parseLinkHeaderResponse(response);
        } catch(Exception E) {
            return new APIHttpResponse();
        }
    }
public static APIHttpResponse httpPut ( String putURL , Context context ) { if ( context == null ) { return new APIHttpResponse ( ) ; } try { putURL = Masquerading . addMasqueradeId ( putURL , context ) ; putURL = putURL . replace ( " " , "%20" ) ; String api_protocol = APIHelpers . loadProtocol ( context ) ; if ( ! putURL . startsWith ( "https://" ) && ! putURL . startsWith ( "http://" ) ) { putURL = api_protocol + "://" + APIHelpers . getDomain ( context ) + "/" + putURL ; } HttpPut get = new HttpPut ( putURL ) ; String token = APIHelpers . getToken ( context ) ; if ( token != null ) { String headerValue = String . format ( "Bearer %s" , token ) ; get . addHeader ( "Authorization" , headerValue ) ; } HttpClient client = getHttpClient ( context ) ; HttpResponse response = client . execute ( get ) ; return parseLinkHeaderResponse ( response ) ; } catch ( Exception E ) { return new APIHttpResponse ( ) ; } }
httpPut is a bare-bones implementation for writing HTTPPut requests to the CanvasAPI.
httpPut is a bare - bones implementation for writing HTTPPut requests to the CanvasAPI .
//Explicit check for null. //Remove spaces from the URL //Make sure the URL begins with https://