Code example for HttpUriRequest

Methods: addHeader

0
  } 
 
  private static void addGoogleAuthHeader(HttpUriRequest request, String token) {
    if (token != null) {
      Log.i(LOG_TAG, "adding auth token token: " + token);
      request.addHeader("Authorization", AUTHORIZATION_HEADER_PREFIX  + token);
    } 
  } 
 
  private static void removeGoogleAuthHeaders(HttpUriRequest request) {
    for (Header header : request.getAllHeaders()) {
      if (header.getName().equalsIgnoreCase("Authorization") &&
              header.getValue().startsWith(AUTHORIZATION_HEADER_PREFIX)) {
        Log.i(LOG_TAG, "Removing header:" + header);
        request.removeHeader(header);
      } 
    } 
  } 
 
  /** 
   * Uses Google Account Manager to retrieve auth token that can