private HttpRequest createRequest(String urlStr, Request fullQuery, String requestMethod,
      boolean useOAuth) throws GeneralSecurityException, IOException {
    Map<String, String> postData = fullQuery.getPostData();
    GenericUrl url = new GenericUrl(urlStr);
    if (debug) {
      fullQuery.printDebug();
      logger = Logger.getLogger(HttpTransport.class.getName());
      logger.removeHandler(debugHandler);
      logger.setLevel(Level.ALL);
      logger.addHandler(debugHandler);
    }

    // Configure OAuth request params
    OAuthParameters params = new OAuthParameters();
    params.consumerKey = key;
    params.computeNonce();
    params.computeTimestamp();
    params.signer = signer;

    // generate the signature
    params.computeSignature(requestMethod, url);

    // make the request
    HttpTransport transport = new NetHttpTransport();
    HttpRequestFactory f = null;
    if (useOAuth) {
      f = transport.createRequestFactory(params);
    } else {
      f = transport.createRequestFactory();
    }
    HttpRequest request = null;
    if ("POST".equals(requestMethod))
      if (postData == null)
        request = f.buildPostRequest(url, null);
      else
        request = f.buildPostRequest(url, new UrlEncodedContent(postData));
    else
      request = f.buildGetRequest(url);

    if (readTimeout != -1)
      request.setReadTimeout(readTimeout);
    if (connectionTimeout != -1)
      request.setConnectTimeout(connectionTimeout);

    HttpHeaders headers = new HttpHeaders();
    headers.set("X-Factual-Lib", DRIVER_HEADER_TAG);
    headers.set("Host", host);
    request.setHeaders(headers);
    return request;
  }