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 HTTPSocket(HTTPSocket socket) { setSocket(socket.getSocket()); setInputStream(socket.getInputStream()); setOutputStream(socket.getOutputStream()); }
public String getLocalAddress() { return getSocket().getLocalAddress(); }
public int getLocalPort() { return getSocket().getLocalPort(); }
public HTTPResponse(HTTPSocket httpSock) { this(httpSock.getInputStream()); }
public boolean post(HTTPResponse httpRes, long contentOffset, long contentLength, boolean isOnlyHeader) { //TODO Close if Connection != keep-alive if (httpRes.hasContentInputStream() == true) return post(httpRes,httpRes.getContentInputStream(), contentOffset, contentLength, isOnlyHeader); return post(httpRes,httpRes.getContent(), contentOffset, contentLength, isOnlyHeader); } }
OutputStream out = getOutputStream();
public int getLocalPort() { return getSocket().getLocalPort(); }
public void finalize() { close(); }
public boolean open() { Socket sock = getSocket(); try { sockIn = sock.getInputStream(); sockOut = sock.getOutputStream(); } catch (Exception e) { //TODO Add blacklistening of the UPnP Device return false; } return true; }
public HTTPRequest(HTTPSocket httpSock) { this(httpSock.getInputStream()); setSocket(httpSock); }
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(); }
OutputStream out = getOutputStream();
public int getLocalPort() { return getSocket().getLocalPort(); }
public void finalize() { close(); }
public HTTPSocket(HTTPSocket socket) { setSocket(socket.getSocket()); setInputStream(socket.getInputStream()); setOutputStream(socket.getOutputStream()); }
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(); } }