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();
		System.out.print("Incoming request: ");
		for (String key : requestHeaders.keySet()) {
			System.out.print(key + ":" + requestHeaders.get(key) + "; ");
		}
		System.out.println();

		// 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!");
		}
		System.out.println("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 = Ranker.Factory.getRankerByArguments(cgiArgs,
				SearchEngine.OPTIONS, _indexer);
		if (ranker == null) {
			respondWithMsg(exchange, "Ranker " + cgiArgs._rankerType.toString()
					+ " is not valid!");
		}

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

		// Ranking.		
		long start = System.currentTimeMillis();
		Vector<ScoredDocument> scoredDocs = ranker.runQuery(processedQuery,
				cgiArgs._numResults);
		long end = System.currentTimeMillis();
		StringBuffer response = new StringBuffer();
		
		response.append("Time required : " + (end - start) + "ms\n\n");
		switch (cgiArgs._outputFormat) {
		case TEXT:
			constructTextOutput(scoredDocs, response);
			break;
		case HTML:
			// @CS2580: Plug in your HTML output
			break;
		default:
			// nothing
		}
		respondWithMsg(exchange, response.toString());
		System.out.println("Finished query: " + cgiArgs._query);
	}