コード例 #1
0
  private void serviceClient(Socket clientSocket) {
    IHttpRequest request;
    IHttpResponse response;

    // pour éviter un blocage dans le serveur
    try {
      clientSocket.setSoTimeout(10000);
    } catch (SocketException e) {
      logger.error(e.getMessage());
      try {
        clientSocket.close();
      } catch (IOException e1) {
        logger.error(e1.getMessage());
      }
      return;
    }

    HttpClient httpClient = new HttpClient(clientSocket);

    try {
      request = httpClient.getHttpRequest();
      logger.info("receive :\n" + request);
      response = process.run(request);
    } catch (IOException | MethodeTypeException e) {
      logger.error(e.getMessage());
      response = DefaultResponseFactory.createResponseBadRequestException(e);
    }

    httpClient.sendHttpResponse(response);
    httpClient.shutdown();
  }
コード例 #2
0
 @Override
 public void abort() {
   client.shutdown();
 }