@Test public void testCustomHeader() throws Exception { Interceptor.Builder builder = InterceptorBuilderFactory.newInstance( InterceptorType.HOST.toString()); Context ctx = new Context(); ctx.put("preserveExisting", "false"); ctx.put("hostHeader", "hostname"); builder.configure(ctx); Interceptor interceptor = builder.build(); Event eventBeforeIntercept = EventBuilder.withBody("test event", Charsets.UTF_8); Assert.assertNull(eventBeforeIntercept.getHeaders().get("hostname")); Event eventAfterIntercept = interceptor.intercept(eventBeforeIntercept); String actualHost = eventAfterIntercept.getHeaders().get("hostname"); Assert.assertNotNull(actualHost); Assert.assertEquals(InetAddress.getLocalHost().getHostAddress(), actualHost); }
@Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(header)) { return event; } if (host != null) { headers.put(header, host); } return event; }
HostInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(header)) { return event; } if (host != null) { headers.put(header, host); } return event; } }
HostInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(header)) { return event; } if (host != null) { headers.put(header, host); } return event; } private  HostInterceptor(boolean preserveExisting,
      boolean useIP, String header); }
HostInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(header)) { return event; } if (host != null) { headers.put(header, host); } return event; } private  HostInterceptor(boolean preserveExisting,
      boolean useIP, String header); @Override void initialize(); @Override Event intercept(Event event); @Override List<Event> intercept(List<Event> events); @Override void close(); }
HostInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(header)) { return event; } if (host != null) { headers.put(header, host); } return event; } private  HostInterceptor(boolean preserveExisting,
      boolean useIP, String header); @Override void initialize(); @Override Event intercept(Event event); @Override List<Event> intercept(List<Event> events); @Override void close();  }