use of lucee.runtime.PageContext in project Lucee by lucee.
the class HTTPServletRequestWrap method getInputStream.
@Override
public ServletInputStream getInputStream() throws IOException {
// if(ba rr!=null) throw new IllegalStateException();
if (barr == null) {
if (!firstRead) {
PageContext pc = ThreadLocalPageContext.get();
if (pc != null) {
return pc.formScope().getInputStream();
}
// throw new IllegalStateException();
return new ServletInputStreamDummy(new byte[] {});
}
firstRead = false;
if (isToBig(getContentLength())) {
return req.getInputStream();
}
InputStream is = null;
try {
barr = IOUtil.toBytes(is = req.getInputStream());
// Resource res = ResourcesImpl.getFileResourceProvider().getResource("/Users/mic/Temp/multipart.txt");
// IOUtil.copy(new ByteArrayInputStream(barr), res, true);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
barr = null;
return new ServletInputStreamDummy(new byte[] {});
} finally {
IOUtil.closeEL(is);
}
}
return new ServletInputStreamDummy(barr);
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class HttpUtil method cloneParameters.
public static Pair<String, String>[] cloneParameters(HttpServletRequest req) {
List<Pair<String, String>> parameters = new ArrayList<Pair<String, String>>();
Enumeration e = req.getParameterNames();
String[] values;
String name;
while (e.hasMoreElements()) {
name = (String) e.nextElement();
values = req.getParameterValues(name);
if (values == null && ReqRspUtil.needEncoding(name, false))
values = req.getParameterValues(ReqRspUtil.encode(name, ReqRspUtil.getCharacterEncoding(null, req)));
if (values == null) {
PageContext pc = ThreadLocalPageContext.get();
if (pc != null && ReqRspUtil.identical(pc.getHttpServletRequest(), req)) {
values = HTTPServletRequestWrap.getParameterValues(ThreadLocalPageContext.get(), name);
}
}
if (values != null)
for (int i = 0; i < values.length; i++) {
parameters.add(new Pair<String, String>(name, values[i]));
}
}
return parameters.toArray(new Pair[parameters.size()]);
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class RequestDispatcherWrap method include.
@Override
public void include(ServletRequest req, ServletResponse rsp) throws ServletException, IOException {
PageContext pc = ThreadLocalPageContext.get();
if (pc == null) {
this.req.getOriginalRequestDispatcher(realPath).include(req, rsp);
return;
}
HTTPUtil.include(pc, req, rsp, realPath);
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class TagUtil method addTagMetaData.
/**
* load metadata from cfc based custom tags and add the info to the tag
* @param cs
* @param config
*/
public static void addTagMetaData(ConfigWebImpl cw) {
if (true)
return;
PageContextImpl pc = null;
try {
pc = ThreadUtil.createPageContext(cw, DevNullOutputStream.DEV_NULL_OUTPUT_STREAM, "localhost", "/", "", new Cookie[0], new Pair[0], null, new Pair[0], new StructImpl(), false, -1);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
return;
}
PageContext orgPC = ThreadLocalPageContext.get();
try {
ThreadLocalPageContext.register(pc);
// MUST MOST of them are the same, so this is a huge overhead
_addTagMetaData(pc, cw, CFMLEngine.DIALECT_CFML);
_addTagMetaData(pc, cw, CFMLEngine.DIALECT_LUCEE);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
} finally {
pc.getConfig().getFactory().releaseLuceePageContext(pc, true);
ThreadLocalPageContext.register(orgPC);
}
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class ThreadTag method getThreadScopeNames.
public static java.util.Collection<String> getThreadScopeNames(PageContext pc, int level) {
String[] names = null;
java.util.Collection<String> result = new HashSet<String>();
// current
if ((level & LEVEL_CURRENT) > 0) {
names = pc.getThreadScopeNames();
if (names != null)
for (int i = 0; i < names.length; i++) {
result.add(names[i]);
}
}
// parent
if ((level & LEVEL_PARENTS) > 0) {
PageContext parent = pc.getParentPageContext();
while (parent != null) {
names = parent.getThreadScopeNames();
if (names != null)
for (int i = 0; i < names.length; i++) {
result.add(names[i]);
}
parent = parent.getParentPageContext();
}
}
// children
if ((level & LEVEL_KIDS) > 0 && pc.hasFamily()) {
getKidsThreadScopeNames(((PageContextImpl) pc).getChildPageContexts(), result, 0);
}
return result;
}
Aggregations