java - Read HttpServletResponse headers and body in Apache Camel jetty component -
i trying create http proxy server using apache camel jetty component. next code -
from("jetty:http://localhost:8080?matchonuriprefix=true") .process(new processor() { public void process(exchange exchange) throws exception { httpservletrequest req = exchange.getin().getbody( httpservletrequest.class); enumeration<string> headers = request.getheadernames(); while (headers.hasmoreelements()) { string headername = headers.nextelement(); string headervalue = request.getheader(headername); } inputstream stream = request.getinputstream(); int bytesread; string line = ""; byte b[] = new byte[1024]; while ((bytesread = stream.read(b)) != -1) { line = line + new string(b, 0, bytesread); } }) .to("http://www.google.com:80?bridgeendpoint=true&throwexceptiononfailure=false") .process(new processor() { public void process(exchange exchange) throws exception { httpservletresponse res = exchange.getin().getbody( httpservletresponse.class); });
i able read httpservletrequest headers , data. however, not able read httpservletresponse info there no getinputstream() method in httpservletresponse. found post related problem said either have subclass httpservletresponse or create filter. in apache camel, not straight interacting httpservletresponse class how can sub class or create filter
please help me resolve problem.
java servlets jetty apache-camel proxy-server
No comments:
Post a Comment