001 /** 002 * Implements the CFML Function gethttprequestdata 003 */ 004 package railo.runtime.functions.other; 005 006 import java.util.Enumeration; 007 008 import javax.servlet.http.HttpServletRequest; 009 010 import railo.runtime.PageContext; 011 import railo.runtime.exp.PageException; 012 import railo.runtime.ext.function.Function; 013 import railo.runtime.net.http.ReqRspUtil; 014 import railo.runtime.type.KeyImpl; 015 import railo.runtime.type.Struct; 016 import railo.runtime.type.StructImpl; 017 import railo.runtime.type.util.KeyConstants; 018 019 public final class GetHTTPRequestData implements Function { 020 021 private static final long serialVersionUID = 1365182999286292317L; 022 023 public static Struct call(PageContext pc ) throws PageException { 024 025 Struct sct=new StructImpl(); 026 Struct headers=new StructImpl(); 027 HttpServletRequest req = pc.getHttpServletRequest(); 028 String charset = pc.getConfig().getWebCharset(); 029 // headers 030 Enumeration e = req.getHeaderNames(); 031 while(e.hasMoreElements()) { 032 String key=e.nextElement().toString(); 033 headers.set(KeyImpl.init(ReqRspUtil.decode(key, charset,false)),ReqRspUtil.decode(req.getHeader(key),charset,false)); 034 } 035 sct.set(KeyConstants._headers, headers); 036 sct.set(KeyConstants._protocol,req.getProtocol()); 037 sct.set(KeyConstants._method,req.getMethod()); 038 sct.set(KeyConstants._content,ReqRspUtil.getRequestBody(pc,false,"")); 039 return sct; 040 } 041 }