use of org.apache.hc.core5.http.copied.NameValuePair in project httpcomponents-core by apache.
the class BasicHeaderValueParser method parseParameters.
@Override
public NameValuePair[] parseParameters(final CharSequence buffer, final ParserCursor cursor) {
Args.notNull(buffer, "Char sequence");
Args.notNull(cursor, "Parser cursor");
tokenizer.skipWhiteSpace(buffer, cursor);
final List<NameValuePair> params = new ArrayList<>();
while (!cursor.atEnd()) {
final NameValuePair param = parseNameValuePair(buffer, cursor);
params.add(param);
final char ch = buffer.charAt(cursor.getPos() - 1);
if (ch == ELEM_DELIMITER) {
break;
}
}
return params.toArray(EMPTY_NAME_VALUE_ARRAY);
}
use of org.apache.hc.core5.http.copied.NameValuePair in project httpcomponents-core by apache.
the class BasicHeaderValueParser method parseHeaderElement.
@Override
public HeaderElement parseHeaderElement(final CharSequence buffer, final ParserCursor cursor) {
Args.notNull(buffer, "Char sequence");
Args.notNull(cursor, "Parser cursor");
final NameValuePair nvp = parseNameValuePair(buffer, cursor);
NameValuePair[] params = null;
if (!cursor.atEnd()) {
final char ch = buffer.charAt(cursor.getPos() - 1);
if (ch != ELEM_DELIMITER) {
params = parseParameters(buffer, cursor);
}
}
return new BasicHeaderElement(nvp.getName(), nvp.getValue(), params);
}
use of org.apache.hc.core5.http.copied.NameValuePair in project geo-platform by geosdi.
the class CatalogContextTest method setUp.
@Before
public void setUp() throws Exception {
try {
CloseableHttpClient client = HttpClients.createDefault();
List<NameValuePair> qparams = new ArrayList<NameValuePair>();
qparams.add(new BasicNameValuePair("SERVICE", "CSW"));
qparams.add(new BasicNameValuePair("REQUEST", "GetCapabilities"));
URI uri = new URIBuilder().setScheme("http").setHost(CSW_HOST).setPath(CSW_PATH).addParameters(qparams).build();
HttpGet get = new HttpGet(uri);
CloseableHttpResponse response = client.execute(get);
this.entity = response.getEntity();
} catch (URISyntaxException ex) {
logger.error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " + ex.getMessage());
} catch (ClientProtocolException ex) {
logger.error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " + ex.getMessage());
} catch (IOException ex) {
logger.error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " + ex.getMessage());
}
}
use of org.apache.hc.core5.http.copied.NameValuePair in project spotify-web-api-java by spotify-web-api-java.
the class AbstractRequest method bodyParametersToJson.
public String bodyParametersToJson(List<NameValuePair> bodyParameters) {
JsonObject jsonObject = new JsonObject();
JsonElement jsonElement;
for (NameValuePair nameValuePair : bodyParameters) {
try {
jsonElement = JsonParser.parseString(nameValuePair.getValue());
} catch (JsonSyntaxException e) {
jsonElement = new JsonPrimitive(nameValuePair.getValue());
}
jsonObject.add(nameValuePair.getName(), jsonElement);
}
return jsonObject.toString();
}
use of org.apache.hc.core5.http.copied.NameValuePair in project spotify-web-api-java by spotify-web-api-java.
the class Assertions method assertHasBodyParameter.
public static <RT, T> void assertHasBodyParameter(IRequest<RT> request, String name, T value) {
List<NameValuePair> bodyParameters = request.getBodyParameters();
for (NameValuePair bodyParameter : bodyParameters) {
if (bodyParameter.getName().equals(name) && bodyParameter.getValue().equals(String.valueOf(value))) {
return;
}
}
fail(String.format("Request \"%s\" does not contain form parameter \"%s\" with value \"%s\"", request.getClass().getSimpleName(), name, value));
}
Aggregations