0

I have tiny Java web application backed by Apache Camel. It uses Camel's servlet component. This application is meant to be connector and receive data from devices.

As far as we pay for traffic I am interesting if there is a way to deny all response headers from web server and send only status code.

Update:

from("servlet:///channel?servletName=ChannelServlet")

...

.split().method("objectSplitter", "splitRootObject")
.log("before removeHeaders")
.removeHeaders("*")
.log("after removeHeaders")
.process(new Processor() {

    @Override
    public void process(Exchange exchange) throws Exception {
        Message out = exchange.getOut();
        out.removeHeaders("*");
        out.setHeader("custom", "custom");
        out.setHeader(Exchange.HTTP_RESPONSE_CODE, "200");
        out.setBody("");
        LOG.debug("In processor");
    }
});

I am always receiving:

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Host: localhost:8080
charset: utf-8
breadcrumbId: ID-eclipse-46977-1369749855622-0-2
User-Agent: Java/1.7.0_21
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Type: application/octet-stream
Server: Jetty(7.6.8.v20121106)

At the end of stacktrace:

[          http-bio-9080-exec-5] route1                         INFO  before removeHeaders
[          http-bio-9080-exec-5] Tracer                         INFO  ID-eclipse-43869-1369751726247-0-12 >>> (route1) log[before removeHeaders] --> removeHeaders[*] <<< Pattern:InOut, Headers:{frame=0, imei=393090335172229, type=SdkMsgFrame, genTime=0, breadcrumbId=ID-eclipse-43869-1369751726247-0-11, key=2aa4678e-2eb8-42c2-9b59-2e816c276cd5, numFrames=1}, BodyType:String, Body:eNo1...Q1GJ+
[          http-bio-9080-exec-5] Tracer                         INFO  ID-eclipse-43869-1369751726247-0-12 >>> (route1) removeHeaders[*] --> log[after removeHeaders] <<< Pattern:InOut, BodyType:String, Body:eNo1...Q1GJ+
[          http-bio-9080-exec-5] route1                         INFO  after removeHeaders
[          http-bio-9080-exec-5] Tracer                         INFO  ID-eclipse-43869-1369751726247-0-12 >>> (route1) log[after removeHeaders] --> com.succorfish.harbour.http.route.ServletRoute$1@17968bee <<< Pattern:InOut, BodyType:String, Body:eNo1...Q1GJ+
[          http-bio-9080-exec-5] ServletRoute                   DEBUG In processor
[          http-bio-9080-exec-5] MulticastProcessor             DEBUG Done sequential processing 1 exchanges
4

2 回答 2

1

您可以告诉 Camel 删除路线末端的所有标头。然后响应没有任何标题。

from("jetty:...")
   ...
   .removeHeaders("*");

另请参阅其中一些页面

于 2013-05-28T13:47:39.973 回答
0

这个问题的最终答案是您可以从 Camel 中删除大部分标头,但 Tomcat/Jetty 无论如何都会附加其中的一些标头。我得到的最小的标题是:

Date: Thu, 30 May 2013 09:49:30 GMT
Transfer-Encoding: chunked
Content-Length: 0
Server: Apache-Coyote/1.1

在我的情况下这仍然是不可接受的,所以我将使用 Apache Mina 和 UDP/TCP 而不是 HTTP。

于 2013-05-30T09:54:34.313 回答