use of com.predic8.membrane.core.http.Header in project service-proxy by membrane.
the class REST2SOAPInterceptor method modifyRequest.
private void modifyRequest(AbstractExchange exc, Mapping mapping) {
exc.getRequest().setMethod("POST");
exc.getRequest().getHeader().setSOAPAction(mapping.soapAction);
Header header = exc.getRequest().getHeader();
header.removeFields(Header.CONTENT_TYPE);
header.setContentType(isSOAP12(exc) ? MimeType.APPLICATION_SOAP : MimeType.TEXT_XML_UTF8);
exc.setProperty("mapping", mapping);
setServiceEndpoint(exc, mapping);
}
use of com.predic8.membrane.core.http.Header in project service-proxy by membrane.
the class DynamicRegistration method registerWithCallbackAt.
public Client registerWithCallbackAt(String callbackUri, String registrationEndpoint) throws Exception {
Exchange exc = new Request.Builder().post(registrationEndpoint).header(Header.CONTENT_TYPE, MimeType.APPLICATION_JSON_UTF8).body(getRegistrationBody(callbackUri)).buildExchange();
Response response = doRequest(exc);
HashMap<String, String> json = Util.parseSimpleJSONResponse(response);
if (!json.containsKey("client_id") || !json.containsKey("client_secret"))
throw new RuntimeException("Registration endpoint didn't return clientId/clientSecret");
return new Client(json.get("client_id"), json.get("client_secret"), "");
}
use of com.predic8.membrane.core.http.Header in project service-proxy by membrane.
the class MessageAnalyserTest method getRequest.
private Exchange getRequest(String path) throws IOException {
Exchange exc = new Exchange(null);
Request req = new Request();
req.create("POST", "http://test", "HTTP/", new Header(), getClass().getClassLoader().getResourceAsStream(path));
exc.setRequest(req);
return exc;
}
use of com.predic8.membrane.core.http.Header in project service-proxy by membrane.
the class RegExReplaceInterceptorTest method testReplaceBinary.
@Test
public void testReplaceBinary() throws Exception {
String example = "Hello";
RegExReplaceInterceptor regexp = new RegExReplaceInterceptor();
regexp.setRegex(Pattern.quote(example));
regexp.setReplace("Membrane");
Exchange exc = new Request.Builder().body(example).header("Content-Type", "text/plain").buildExchange();
regexp.handleRequest(exc);
assertTrue(exc.getRequest().getBodyAsStringDecoded().equals("Membrane"));
exc = new Request.Builder().body(example).header("Content-Type", "application/octet-stream").buildExchange();
regexp.handleRequest(exc);
assertTrue(exc.getRequest().getBodyAsStringDecoded().equals(example));
}
use of com.predic8.membrane.core.http.Header in project service-proxy by membrane.
the class LimitedMemoryExchangeStoreTest method getExchange.
private Exchange getExchange(String id) throws IOException {
Exchange exc = new Exchange(null);
exc.setProperty("id", id);
Request req = new Request();
req.create("GET", "http://test", "HTTP/", new Header(), null);
exc.setRequest(req);
exc.setResponse(Response.ok().body("<xml />").build());
return exc;
}
Aggregations