src/main/java/com/instructure/canvasapi/api/compatibility_synchronous/HttpHelpers.java
/**
     * parseLinkHeaderResponse is the old way of parsing the pagination URLs out of the response.
     * @param response
     * @return
     */
parseLinkHeaderResponse is the old way of parsing the pagination URLs out of the response.
@param response
@return
parseLinkHeaderResponse is the old way of parsing the pagination URLs out of the response . @param response @return
private static APIHttpResponse parseLinkHeaderResponse(HttpResponse response) {
        APIHttpResponse httpResponse = new APIHttpResponse();
        httpResponse.responseCode = response.getStatusLine().getStatusCode();
        if (httpResponse.responseCode != 204) {
            try
            {
                httpResponse.responseBody = EntityUtils.toString(response.getEntity());
            }
            catch(Exception E) {}
        }
        Header[] linkHeader = response.getHeaders("Link");
        for(int j = 0; j < linkHeader.length; j++) {
            HeaderElement[] elements = linkHeader[j].getElements();
            for(int i = 0; i < elements.length;i ++) {
                String first = elements[i].getName();
                String last = elements[i].getValue();
                String url = first+"="+last;
                if(url.startsWith("<") && url.endsWith(">")) {
                    url = url.substring(1, url.length()-1);
                } else {
                    continue;
                }
                for(int k = 0; k < elements[i].getParameterCount(); k++) {
                    NameValuePair nvp = elements[i].getParameter(k);
                    if(nvp.getName().equals("rel"))
                    {
                        if(nvp.getValue().equals("prev"))
                        {
                            httpResponse.prevURL = url;
                        }
                        else if(nvp.getValue().equals("next"))
                        {
                            httpResponse.nextURL = url;
                        }
                        else if(nvp.getValue().equals("first"))
                        {
                            httpResponse.firstURL = url;
                        }
                        else if(nvp.getValue().equals("last"))
                        {
                            httpResponse.lastURL = url;
                        }
                    }
                }
            }
        }
        return httpResponse;
    }
private static APIHttpResponse parseLinkHeaderResponse ( HttpResponse response ) { APIHttpResponse httpResponse = new APIHttpResponse ( ) ; httpResponse . responseCode = response . getStatusLine ( ) . getStatusCode ( ) ; if ( httpResponse . responseCode != 204 ) { try { httpResponse . responseBody = EntityUtils . toString ( response . getEntity ( ) ) ; } catch ( Exception E ) { } } Header [ ] linkHeader = response . getHeaders ( "Link" ) ; for ( int j = 0 ; j < linkHeader . length ; j ++ ) { HeaderElement [ ] elements = linkHeader [ j ] . getElements ( ) ; for ( int i = 0 ; i < elements . length ; i ++ ) { String first = elements [ i ] . getName ( ) ; String last = elements [ i ] . getValue ( ) ; String url = first + "=" + last ; if ( url . startsWith ( "<" ) && url . endsWith ( ">" ) ) { url = url . substring ( 1 , url . length ( ) - 1 ) ; } else { continue ; } for ( int k = 0 ; k < elements [ i ] . getParameterCount ( ) ; k ++ ) { NameValuePair nvp = elements [ i ] . getParameter ( k ) ; if ( nvp . getName ( ) . equals ( "rel" ) ) { if ( nvp . getValue ( ) . equals ( "prev" ) ) { httpResponse . prevURL = url ; } else if ( nvp . getValue ( ) . equals ( "next" ) ) { httpResponse . nextURL = url ; } else if ( nvp . getValue ( ) . equals ( "first" ) ) { httpResponse . firstURL = url ; } else if ( nvp . getValue ( ) . equals ( "last" ) ) { httpResponse . lastURL = url ; } } } } } return httpResponse ; }
parseLinkHeaderResponse is the old way of parsing the pagination URLs out of the response.
parseLinkHeaderResponse is the old way of parsing the pagination URLs out of the response .
//Get status code. // Check if response is supposed to have a body //Seems to strip out the equals between name and value