org.brutusin.demo.http.HttpAwareAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rpc-demo Show documentation
Show all versions of rpc-demo Show documentation
Demo app for brutusin:rcp
The newest version!
package org.brutusin.demo.http;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.brutusin.rpc.http.Cacheable;
import org.brutusin.rpc.http.HttpActionContext;
import org.brutusin.rpc.http.SafeAction;
public class HttpAwareAction extends SafeAction> {
@Override
public Cacheable> execute(Void input) throws Exception {
Object request = HttpActionContext.getInstance().getRequest();
if (!(request instanceof HttpServletRequest)) {
throw new RuntimeException("Could not get the HttpServletRequest from the context");
} else {
HttpServletRequest httpReq = (HttpServletRequest) request;
List ret = new ArrayList();
Enumeration headerNames = httpReq.getHeaderNames();
while (headerNames.hasMoreElements()) {
String header = headerNames.nextElement();
ret.add(header + ":" + httpReq.getHeader(header));
}
return Cacheable.never(ret);
}
}
}