private void setHeaders(JsonElement headers) { JsonArray array_headers = JsonUtils.asJsonArray(headers); if (array_headers != null) { for (JsonElement jHeader : array_headers) { JsonObject header = JsonUtils.asJsonObject(jHeader); String name = header.get("name").getAsString(); String value = header.get("value").getAsString(); this.addHeader(name, value); if (Parameter.isParameter(value)) { this.addParameter(new Parameter(value)); } } } }
private void setQueryString(JsonElement queryStringParams) { JsonArray array_params = JsonUtils.asJsonArray(queryStringParams); if (array_params != null) { for (JsonElement jQueryParam : array_params) { JsonObject queryParam = JsonUtils.asJsonObject(jQueryParam); String name = queryParam.get("name").getAsString(); String value = queryParam.get("value").getAsString(); this.addQueryStringParam(name, value); if (Parameter.isParameter(value)) { this.addParameter(new Parameter(value)); } } } }
private void setPostData(JsonElement jsonPostData) { JsonArray array_postDataParams = null; if (jsonPostData != null) array_postDataParams = JsonUtils.asJsonArray(jsonPostData); if (array_postDataParams != null) { for (JsonElement postParam : array_postDataParams) { JsonObject param = JsonUtils.asJsonObject(postParam); String name = param.get("name").getAsString(); String value = param.get("value").getAsString(); this.addPostData(name, value); if (Parameter.isParameter(value)) { this.addParameter(new Parameter(value)); } } } else { // Log if postData is empty for POST request (it shouldn't be) if ("POST".equals(this.getMethod())) { System.out.println("WARNING: POST request to " + this.getUrl() + " contains no postData"); } } }