in.total = len;
if (in.next())
{
if (in.name().length() > 0)
hq.getSession().setAttribute(up = PROGRESS.concat(in.name()), in);
Bytes s = new Bytes(in, false);
len = s.byteN();
q = String2.utf(s.bytes, s.beginBi, len);
in.next();
}
if (inf.reqUpload)
extraQs = new Object[] { in };
}
else if (len > 0)
{
InputStream in = hq.getInputStream();
byte[] s = new byte[len];
for (int begin = 0, done; begin < len; begin += done)
if ((done = in.read(s, begin, len - begin)) < 0)
throw new EOFException();
q = String2.utf(s);
}
else if (hq.getQueryString() != null)
q = URLDecoder.decode(hq.getQueryString(), "UTF-8").toCharArray();
Container c = con.create();
c.set(HttpServletRequest.class, hq);
c.set(HttpServletResponse.class, hp);
c.set(HttpSession.class, hq.getSession());
c.set(String.class, "application/octet-stream");
Object p;
try
{
p = handler.handle(c, inf, q, 0, q.length, extraQs);
}
catch (RuntimeException e)
{
throw e;
}
catch (IOException e)
{
throw e;
}
catch (Exception e)
{
throw new ServletException(e);
}
finally
{
if ( !String2.empty(up))
hq.getSession().removeAttribute(up);
}
if (p == null)
throw null;
if (p instanceof CharSequence)
{
if (up != null)
{
hp.setContentType("text/html; charset=UTF-8");
CharSequence r = (CharSequence)p;
StringBuilder s = new StringBuilder();
s.append("<pre id=objot>");
for (int i = 0; i < r.length(); i++)
if (r.charAt(i) == '&')
s.append("&");
else if (r.charAt(i) == '<')
s.append("<");
else
s.append(r.charAt(i));
p = s.append("</pre>").toString();
}
byte[] bs = String2.utf((CharSequence)p);
hp.setContentLength(bs.length);
hp.getOutputStream().write(bs);
}