1 30 package org.apache.commons.httpclient; 31 32 import java.io.IOException ; 33 34 import org.apache.commons.httpclient.server.HttpService; 35 import org.apache.commons.httpclient.server.SimpleRequest; 36 import org.apache.commons.httpclient.server.SimpleResponse; 37 38 39 42 public class EchoService implements HttpService { 43 44 public EchoService() { 45 super(); 46 } 47 48 public boolean process(final SimpleRequest request, final SimpleResponse response) 49 throws IOException 50 { 51 HttpVersion httpversion = request.getRequestLine().getHttpVersion(); 52 response.setStatusLine(httpversion, HttpStatus.SC_OK); 53 if (request.containsHeader("Content-Length")) { 54 response.addHeader(request.getFirstHeader("Content-Length")); 55 } 56 if (request.containsHeader("Content-Type")) { 57 response.addHeader(request.getFirstHeader("Content-Type")); 58 } 59 response.setBodyString(request.getBodyString()); 60 return true; 61 } 62 } 63 | Popular Tags |