code: public void setSecure(boolean isSecure) throws URIException {
          mIsSecure = isSecure;
  
          if (mUri == null) {
              // mUri not yet set
              return;
          }
  
          URI newUri = mUri;
  
          // check if URI consistent
          if (isSecure() && mUri.getScheme().equalsIgnoreCase(HTTP)) {
              newUri = new URI(mUri.toString().replaceFirst(HTTP, HTTPS), true);
              
          } else if (!isSecure() && mUri.getScheme().equalsIgnoreCase(HTTPS)) {
              newUri = new URI(mUri.toString().replaceFirst(HTTPS, HTTP), true);
          }
  
          if (newUri != mUri) {
              mUri = newUri;
              setHostPort(mUri.getPort());
          }
      }
docs: Sets whether or not the request is done using a secure scheme, HTTPS.
  
  @param isSecure {@code true} if the request should be secure, {@code false} otherwise
  @throws URIException if an error occurred while rebuilding the request URI