public String getFirstLineString() { return getMethod() + " " + getURI() + " " + getHTTPVersion() + HTTP.CRLF; }
HTTPRequest httpReq = new HTTPRequest(); httpReq.setMethod(HTTP.GET); httpReq.setURI(uri); HTTPResponse httpRes = httpReq.post(host, port); if (httpRes.isSuccessful() == false) throw new ParserException("HTTP comunication failed: no answer from peer." +
public void httpRequestRecieved(HTTPRequest httpReq) { if (Debug.isOn() == true) httpReq.print(); if (hasPresentationListener() && isPresentationRequest(httpReq)) { PresentationListener listener = getPresentationListener(); listener.httpRequestRecieved(httpReq); return; } if (httpReq.isGetRequest() == true || httpReq.isHeadRequest() == true) { httpGetRequestRecieved(httpReq); return; } if (httpReq.isPostRequest() == true) { httpPostRequestRecieved(httpReq); return; } if (httpReq.isSubscribeRequest() == true || httpReq.isUnsubscribeRequest() == true) { SubscriptionRequest subReq = new SubscriptionRequest(httpReq); deviceEventSubscriptionRecieved(subReq); return; } httpReq.returnBadRequest(); }
private void httpPostRequestRecieved(HTTPRequest httpReq) { if (httpReq.isSOAPAction() == true) { // SOAPRequest soapReq = new SOAPRequest(httpReq); soapActionRecieved(httpReq); return; } httpReq.returnBadRequest(); }
private boolean isPresentationRequest(HTTPRequest httpReq) { if (!httpReq.isGetRequest()) return false; String urlPath = httpReq.getURI(); if (urlPath == null) return false; String presentationURL = getPresentationURL(); if (presentationURL == null) return false; return urlPath.startsWith(presentationURL); }
public boolean post(HTTPResponse httpRes) { HTTPSocket httpSock = getSocket(); long offset = 0; long length = httpRes.getContentLength(); if (hasContentRange() == true) { long firstPos = getContentRangeFirstPosition(); long lastPos = getContentRangeLastPosition(); // Thanks for Brent Hills (10/26/04) if (lastPos <= 0) lastPos = length - 1; if ((firstPos > length ) || (lastPos > length)) return returnResponse(HTTPStatus.INVALID_RANGE); httpRes.setContentRange(firstPos, lastPos, length); httpRes.setStatusCode(HTTPStatus.PARTIAL_CONTENT); offset = firstPos; length = lastPos - firstPos + 1; } return httpSock.post(httpRes, offset, length, isHeadRequest()); //httpSock.close(); }
private void httpGetRequestRecieved(HTTPRequest httpReq) { String uri = httpReq.getURI(); Debug.message("httpGetRequestRecieved = " + uri); if (uri == null) { httpReq.returnBadRequest(); return; String localAddr = httpReq.getLocalAddress(); if ((localAddr == null) || (localAddr.length() <= 0)) localAddr = HostInterface.getInterface(); fileByte = getDescriptionData(localAddr); } else if ((embDev = getDeviceByDescriptionURI(uri)) != null) { String localAddr = httpReq.getLocalAddress(); contentType = XML.DEFAULT_CONTENT_TYPE; contentLanguage = XML.DEFAULT_CONTENT_LANGUAGE; httpReq.returnBadRequest(); return; httpReq.post(httpRes);
public void httpRequestRecieved(HTTPRequest httpReq) { if (Debug.isOn() == true) httpReq.print(); // Thanks for Giordano Sassaroli <sassarol@cefriel.it> (09/08/03) if (httpReq.isNotifyRequest() == true) { NotifyRequest notifyReq = new NotifyRequest(httpReq); String uuid = notifyReq.getSID(); long seq = notifyReq.getSEQ(); PropertyList props = notifyReq.getPropertyList(); int propCnt = props.size(); for (int n = 0; n < propCnt; n++) { Property prop = props.getProperty(n); String varName = prop.getName(); String varValue = prop.getValue(); performEventListener(uuid, seq, varName, varValue); } httpReq.returnOK(); return; } httpReq.returnBadRequest(); }
public void contentExportRequestRecieved(HTTPRequest httpReq) String uri = httpReq.getURI(); if (uri.startsWith(CONTENT_EXPORT_URI) == false) { httpReq.returnBadRequest(); return; ParameterList paramList = httpReq.getParameterList(); for (int n=0; n<paramList.size(); n++) { Parameter param = paramList.getParameter(n); httpReq.returnBadRequest(); return; httpReq.returnBadRequest(); return; httpReq.returnBadRequest(); return; httpRes.setContentInputStream(contentIn); httpReq.post(httpRes);
public void httpRequestRecieved(HTTPRequest httpReq) { Activator.logger.DEBUG("[Importer] httpRequestRecieved event"); Activator.logger.PACKET(httpReq.toString()); if (httpReq.isNotifyRequest() == true) { Activator.logger.DEBUG("[Importer] Notify Request"); NotifyRequest notifyReq = new NotifyRequest(httpReq); String uuid = notifyReq.getSID(); long seq = notifyReq.getSEQ(); PropertyList props = notifyReq.getPropertyList(); // int propCnt = props.size(); // Hashtable hash = new Hashtable(); // for (int n = 0; n < propCnt; n++) { // Property prop = props.getProperty(n); // String varName = prop.getName(); // String varValue = prop.getValue(); // hash.put(varName, varValue); // } newEventArrived(uuid, seq, props); httpReq.returnOK(); return; } Activator.logger.DEBUG("BAD Request"); httpReq.returnBadRequest(); }
public void run() { HTTPSocket httpSock = new HTTPSocket(sock); if (httpSock.open() == false) return; HTTPRequest httpReq = new HTTPRequest(); httpReq.setSocket(httpSock); while (httpReq.read() == true) { httpServer.performRequestListener(httpReq); if (httpReq.isKeepAlive() == false) break; } httpSock.close(); } }
public HTTPResponse post(String host, int port) { return post(host, port, false); }
public ParameterList getParameterList() { ParameterList paramList = new ParameterList(); String uri = getURI(); if (uri == null) return paramList; int paramIdx = uri.indexOf('?'); if (paramIdx < 0) return paramList; while (0 < paramIdx) { int eqIdx = uri.indexOf('=', (paramIdx+1)); String name = uri.substring(paramIdx+1, eqIdx); int nextParamIdx = uri.indexOf('&', (eqIdx+1)); String value = uri.substring(eqIdx+1, (0 < nextParamIdx) ? nextParamIdx : uri.length()); Parameter param = new Parameter(name, value); paramList.add(param); paramIdx = nextParamIdx; } return paramList; }
public void httpRequestRecieved(HTTPRequest httpReq) { String uri = httpReq.getURI(); if (uri.startsWith(PRESENTATION_URI) == false) { super.httpRequestRecieved(httpReq); return; } Clock clock = Clock.getInstance(); String contents = "<HTML><BODY><H1>" + clock.toString() + "</H1></BODY></HTML>"; HTTPResponse httpRes = new HTTPResponse(); httpRes.setStatusCode(HTTPStatus.OK); httpRes.setContent(contents); httpReq.post(httpRes); }
public void print() { Debug.message(toString()); } }
public String getParameterValue(String name) { ParameterList paramList = getParameterList(); return paramList.getValue(name); }
public boolean post(HTTPResponse httpRes) { HTTPSocket httpSock = getSocket(); long offset = 0; long length = httpRes.getContentLength(); if (hasContentRange() == true) { long firstPos = getContentRangeFirstPosition(); long lastPos = getContentRangeLastPosition(); // Thanks for Brent Hills (10/26/04) if (lastPos <= 0) lastPos = length - 1; if ((firstPos > length ) || (lastPos > length)) return returnResponse(HTTPStatus.INVALID_RANGE); httpRes.setContentRange(firstPos, lastPos, length); httpRes.setStatusCode(HTTPStatus.PARTIAL_CONTENT); offset = firstPos; length = lastPos - firstPos + 1; } return httpSock.post(httpRes, offset, length, isHeadRequest()); //httpSock.close(); }
private void httpGetRequestRecieved(HTTPRequest httpReq) { String uri = httpReq.getURI(); Debug.message("httpGetRequestRecieved = " + uri); if (uri == null) { httpReq.returnBadRequest(); return; String localAddr = httpReq.getLocalAddress(); if ((localAddr == null) || (localAddr.length() <= 0)) localAddr = HostInterface.getInterface(); fileByte = getDescriptionData(localAddr); } else if ((embDev = getDeviceByDescriptionURI(uri)) != null) { String localAddr = httpReq.getLocalAddress(); contentType = XML.DEFAULT_CONTENT_TYPE; contentLanguage = XML.DEFAULT_CONTENT_LANGUAGE; httpReq.returnBadRequest(); return; httpReq.post(httpRes);
public void httpRequestRecieved(HTTPRequest httpReq) { if (Debug.isOn() == true) httpReq.print(); // Thanks for Giordano Sassaroli <sassarol@cefriel.it> (09/08/03) if (httpReq.isNotifyRequest() == true) { NotifyRequest notifyReq = new NotifyRequest(httpReq); String uuid = notifyReq.getSID(); long seq = notifyReq.getSEQ(); PropertyList props = notifyReq.getPropertyList(); int propCnt = props.size(); for (int n = 0; n < propCnt; n++) { Property prop = props.getProperty(n); String varName = prop.getName(); String varValue = prop.getValue(); performEventListener(uuid, seq, varName, varValue); } httpReq.returnOK(); return; } httpReq.returnBadRequest(); }
public void contentExportRequestRecieved(HTTPRequest httpReq) String uri = httpReq.getURI(); if (uri.startsWith(CONTENT_EXPORT_URI) == false) { httpReq.returnBadRequest(); return; ParameterList paramList = httpReq.getParameterList(); for (int n=0; n<paramList.size(); n++) { Parameter param = paramList.getParameter(n); httpReq.returnBadRequest(); return; httpReq.returnBadRequest(); return; httpReq.returnBadRequest(); return; httpRes.setContentInputStream(contentIn); httpReq.post(httpRes);