private void processResponse(RubyValue res) { if (res != null && res != RubyConstant.QNIL && res instanceof RubyHash) { RubyHash resHash = (RubyHash) res; RubyValue resBody = null; RubyArray arKeys = resHash.keys(); RubyArray arValues = resHash.values(); for (int i = 0; i < arKeys.size(); i++) { String strKey = arKeys.get(i).toString(); if (strKey.equals("request-body")) resBody = arValues.get(i); else if (strKey.equals("status")) responseCode = arValues.get(i).toInt(); else if (strKey.equals("message")) responseMsg = arValues.get(i).toString(); else resHeaders.addProperty(strKey, arValues.get(i).toString()); } String strBody = ""; if (resBody != null && resBody != RubyConstant.QNIL) strBody = resBody.toRubyString().toString(); if (!RHOCONF().getBool("log_skip_post")) LOG.TRACE(strBody); try { responseData = new ByteArrayInputStream(strBody.getBytes("UTF-8")); } catch (java.io.UnsupportedEncodingException exc) { LOG.ERROR("Error getting utf-8 body :", exc); } if (responseData != null) contentLength = Integer.parseInt(resHeaders.getPropertyIgnoreCase("Content-Length")); } }
private void processResponse(RubyValue res) { if (res != null && res != RubyConstant.QNIL && res instanceof RubyHash) { RubyHash resHash = (RubyHash) res; RubyValue resBody = null; RubyArray arKeys = resHash.keys(); RubyArray arValues = resHash.values(); for (int i = 0; i < arKeys.size(); i++) { String strKey = arKeys.get(i).toString(); if (strKey.equals("request-body")) resBody = arValues.get(i); else if (strKey.equals("status")) responseCode = arValues.get(i).toInt(); else if (strKey.equals("message")) responseMsg = arValues.get(i).toString(); else resHeaders.addProperty(strKey, arValues.get(i).toString()); } String strBody = ""; if (resBody != null && resBody != RubyConstant.QNIL) strBody = resBody.toRubyString().toString(); log(strBody); responseData = new ByteArrayInputStream(strBody.getBytes()); if (responseData != null) contentLength = Integer.parseInt(resHeaders.getPropertyIgnoreCase("Content-Length")); } }
public void processRequest() throws IOException { if (!requestProcessed) { String strErr = ""; LOG.TRACE("processRequest: " + getURL()); String strReferer = reqHeaders != null ? reqHeaders.getPropertyIgnoreCase("Referer") : ""; if (getRef() != null && getRef().length() > 0 && strReferer != null && strReferer.equalsIgnoreCase(uri_orig.getPathNoFragment())) { respondNotModified(); } else { String strContType = getContentType(); if (uri.getPath().startsWith("/apps/public")) { httpServeFile(strContType); } else { if (this.method.equals("POST") || strContType.length() == 0 || strContType.indexOf("application/x-www-form-urlencoded") >= 0) { if (dispatch()) { requestProcessed = true; return; } } if ( /*this.method == "GET" &&*/ httpGetFile(strContType)) { // }else if ( dispatch() ){ } else { respondNotFound(strErr); } } } requestProcessed = true; } }
public String getRequestProperty(String key) { LOG.TRACE("getRequestProperty: " + key); return reqHeaders.getPropertyIgnoreCase(key); }
public String getHeaderField(String name) throws IOException { LOG.TRACE("getHeaderField: " + name); processRequest(); return resHeaders.getPropertyIgnoreCase(name); }