All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hannesdorfmann.httpkit.HttpKit Maven / Gradle / Ivy

There is a newer version: 1.5.6
Show newest version
package com.hannesdorfmann.httpkit;

import com.hannesdorfmann.httpkit.cache.Cache;
import com.hannesdorfmann.httpkit.parser.ParserWriter;
import com.hannesdorfmann.httpkit.request.HttpRequest;
import com.hannesdorfmann.httpkit.response.HttpResponseReceiver;
import com.hannesdorfmann.httpkit.threading.HttpExecutor;

/**
 * The {@link HttpKit} gives the you the basic functionality to interact with an
 * webserver over the http protocol.
 * 
 * @author Hannes Dorfmann
 * 
 */
public interface HttpKit {

	/**
	 * Sets the internal cache
	 * 
	 * @param cache
	 */
	public void setCache(Cache cache);

	/**
	 * Get the cache that is uses
	 * 
	 * @return
	 */
	public Cache getCache();

	/**
	 * Adds a parser for the given mime type
	 * 
	 * @param mimeType
	 *            The mimetype. The passed parser will be used for this mime
	 *            type
	 * @param parser
	 *            The parser
	 */
	public void addParserWriter(String mimeType, ParserWriter parser);

	/**
	 * Removes the parser for the given mime type
	 * 
	 * @param mimeType
	 */
	public void removeParserWriter(String mimeType);

	/**
	 * Set it to true, if you want to let the {@link HttpKit} automatically
	 * handle the http redirect methods. The http status code would be 302 and
	 * 301
	 * 
	 * @param enabled
	 */
	// public void setAutoHandleHttpRedirect(boolean enabled);

	/**
	 * Executes a {@link HttpRequest} with parsing the result according the
	 * returned mime type. To make this work it's necessary, that the server
	 * returns a correct mime type or was setted in the {@link HttpRequest} and
	 * that a parser has been added to this {@link HttpKit} for the returned
	 * mime type
	 * 
	 * @param request
	 * @param receiver
	 * @see #addParserWriter(String, ParserWriter)
	 */
	public  void execute(HttpRequest request,
			HttpResponseReceiver receiver);

	/**
	 * Set the {@link HttpExecutor} for async http data transfer
	 * 
	 * @param httpExecutor
	 */
	public void setHttpExecutor(HttpExecutor httpExecutor);

	/**
	 * Cancels all pending {@link HttpRequest} that were tagged
	 * 
	 * @param owner
	 */
	public void cancelAllOfOwner(Object owner);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy