Added JsonPage and finished implementation of digest auth page

This commit is contained in:
Ziver Koc 2016-11-04 16:52:10 +01:00
parent 2c7a9a6eff
commit 26c09452f3
10 changed files with 244 additions and 52 deletions

View file

@ -0,0 +1,30 @@
package zutil.net.http;
import zutil.io.StringOutputStream;
import zutil.net.http.page.HttpDigestAuthPageTest;
import java.io.IOException;
import java.util.HashMap;
public class HttpTestUtil {
public static HashMap<String,Object> session = new HashMap();
/**
* Make a simple http request on the given page object
*/
public static HttpHeader makeRequest(HttpPage page) throws IOException {
return makeRequest(page, new HttpHeader());
}
/**
* Make a simple http request on the given page object
*/
public static HttpHeader makeRequest(HttpPage page, HttpHeader headers) throws IOException {
StringOutputStream buff = new StringOutputStream();
HttpPrintStream out = new HttpPrintStream(buff);
page.respond(
out, headers, session, new HashMap(), new HashMap());
out.flush();
HttpHeaderParser parser = new HttpHeaderParser(buff.toString());
return parser.read();
}
}