private void acceptClient(@NotNull Socket client) throws IOException { final SessionInputBuffer inputBuffer = wrapInputStream(client.getInputStream()); final HttpMessageParser<HttpRequest> parser = new DefaultHttpRequestParser(inputBuffer, new BasicLineParser(), new DefaultHttpRequestFactory(), MessageConstraints.DEFAULT ); final SessionOutputBuffer outputBuffer = wrapOutputStream(client.getOutputStream()); final HttpMessageWriter<HttpResponse> writer = new DefaultHttpResponseWriter(outputBuffer); while (!socket.isClosed()) { try { service(inputBuffer, outputBuffer, parser, writer); } catch (ConnectionClosedException ignored) { break; } catch (HttpException e) { log.error(e.getMessage(), e); break; } } }
private HttpRequest getHttpRequest(String user, String pass){ HttpRequestFactory factory = new DefaultHttpRequestFactory(); HttpRequest req = null; String base64 = new String(Base64.encodeBase64( user.concat(":").concat(pass).getBytes())); try { req = factory.newHttpRequest( new BasicRequestLine("POST", "https://localhost:8444/", HttpVersion.HTTP_1_1)); req.addHeader("Accept-Encoding", "gzip,deflate"); req.addHeader("Content-Type", "application/soap+xml;charset=UTF-8"); req.addHeader("User-Agent", "IROND Testsuite/1.0"); req.addHeader("Host", "localhost:8444"); req.addHeader("Content-Length", "198"); req.addHeader("Authorization", "Basic "+base64); } catch (MethodNotSupportedException e) { e.printStackTrace(); } return req; }
public AxisHttpConnectionImpl(final Socket socket, final HttpParams params) throws IOException { super(); if (socket == null) { throw new IllegalArgumentException("Socket may not be null"); } if (params == null) { throw new IllegalArgumentException("HTTP parameters may not be null"); } socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params)); socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params)); int linger = HttpConnectionParams.getLinger(params); if (linger >= 0) { socket.setSoLinger(linger > 0, linger); } int buffersize = HttpConnectionParams.getSocketBufferSize(params); this.socket = socket; this.outbuffer = new SocketOutputBuffer(socket, buffersize, params); this.inbuffer = new SocketInputBuffer(socket, buffersize, params); this.contentLenStrategy = new StrictContentLengthStrategy(); this.requestParser = new HttpRequestParser( this.inbuffer, null, new DefaultHttpRequestFactory(), params); this.responseWriter = new HttpResponseWriter( this.outbuffer, null, params); }