private void populateArgs(JSONObject headers) throws JSONException, UnsupportedEncodingException {
    if (headers != null) {
      // add headers. Handles headers with multiple values.
      Iterator<String> headerKeys = headers.keys();
      while (headerKeys.hasNext()) {
        String headerKey = headerKeys.next();
        Object headerValue = JSONObject.NULL.equals(headers.get(headerKey)) ? null : headers.get(headerKey);
        addOrUpdateArgNoDecoding(headerKey, headerValue);
      }
    }

    // decode parameters in the URI. Handles parameters without values and multiple values for the same parameter.
    if (uri != null && uri.getQuery() != null) {
      for (String parameterValue : uri.getQuery().split("&")) {
        int idx = parameterValue.indexOf("=");
        String key = idx > 0 ? parameterValue.substring(0, idx) : parameterValue;
        String value = idx > 0 ? parameterValue.substring(idx + 1) : null;
        addOrUpdateArg(key, value);
      }
    }

    // convert all StringBuilders to String
    for (Map.Entry<String, Object> e : args.entrySet()) {
      Object value = e.getValue();
      if (value != null && value instanceof StringBuilder) {
        args.put(e.getKey(), (e.getValue()).toString());
      }
    }
  }
Adds all headers and parameters in the URL as arguments.
@param headers headers sent with the request.
@throws UnsupportedEncodingException if an argument key or value cannot be URL decoded.
ambry-test-utils/src/main/java/com/github/ambry/rest/MockRestRequest.java