hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Abele <e...@codefaktor.de>
Subject No Server header until explicitly assigning ORIGIN_SERVER to response
Date Thu, 18 Oct 2007 17:35:06 GMT
While using httpcore-4.0 for a server application I came across an  
issue which can be easily shown by using the ElementalHttpServer  
example:

When running the example I get no Server header:

HTTP/1.1 200 OK
Date: Thu, 18 Oct 2007 16:48:00 GMT
Content-Length: 5599
Content-Type: text/html

After applying the attached patch to ElementalHttpServer.java I get  
the server header:

HTTP/1.1 200 OK
Date: Thu, 18 Oct 2007 16:53:49 GMT
Server: Jakarta-HttpComponents/1.1
Content-Length: 5599
Content-Type: text/html

The problem seems to be that the params used by the instance of  
HttpService are not carried over to the HttpResponse object and  
therefore the ResponseServer interceptor doesn't add the header in  
question - is this intended or am I just too blind?

Cheers,
Erik

--- ElementalHttpServer.java.orig	2007-10-05 12:04:10.000000000 +0200
+++ ElementalHttpServer.java	2007-10-18 19:32:49.000000000 +0200
@@ -104,6 +104,12 @@
                  final HttpResponse response,
                  final HttpContext context) throws HttpException,  
IOException {

+            response.getParams().setParameter 
(CoreProtocolPNames.ORIGIN_SERVER,
+                request.getParams().getParameter 
(CoreProtocolPNames.ORIGIN_SERVER));
+
+            // or alternatively simply:
+            //response.setParams(request.getParams());
+
              String method = request.getRequestLine().getMethod 
().toUpperCase();
              if (!method.equals("GET") && !method.equals("HEAD") && ! 
method.equals("POST")) {
                  throw new MethodNotSupportedException(method + "  
method not supported");


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


Mime
View raw message