public void handle(HttpExchange exchange) throws IOException {
		String requestMethod = exchange.getRequestMethod();
		if (!requestMethod.equalsIgnoreCase("GET")) { // GET requests only.
			return;
		}

		// Print the user request header.
		Headers requestHeaders = exchange.getRequestHeaders();
		_logger.debug("Incoming request: ");
		for (String key : requestHeaders.keySet()) {
			_logger.debug("{} : {} ;", key, requestHeaders.get(key));
		}

		// Validate the incoming request.
		String uriQuery = exchange.getRequestURI().getQuery();
		String uriPath = exchange.getRequestURI().getPath();
		if (uriPath == null || uriQuery == null) {
			respondWithMsg(exchange, "Something wrong with the URI!");
		}
		if (!uriPath.equals("/search")) {
			respondWithMsg(exchange, "Only /search is handled!");
		}
		_logger.debug("Query: {}", uriQuery);

		// Process the CGI arguments.
		CgiArguments cgiArgs = new CgiArguments(uriQuery);
		if (cgiArgs._query.isEmpty()) {
			respondWithMsg(exchange, "No query is given!");
		}

		// Create the ranker.
		Ranker ranker = new RankerFactory(_indexer).create(cgiArgs._rankerType);
		assert ranker != null;

		// Processing the query.
		Query processedQuery = new Query(cgiArgs._query);

		// Ranking.
		Vector<ScoredDocument> scoredDocs = ranker.runQuery(processedQuery,
				cgiArgs._numResults);
		StringBuffer response = new StringBuffer();
		switch (cgiArgs._outputFormat) {
		case TEXT:
			constructTextOutput(scoredDocs, response);
			break;
		case HTML:
			// @CS2580: Plug in your HTML output
			response = convertToString(cgiArgs._query, scoredDocs);
			break;
		default:
			// nothing
		}
		respondWithMsg(exchange, response.toString());
		_logger.debug("Finished query: {}", cgiArgs._query);
	}