本文整理汇总了Java中fi.iki.elonen.NanoHTTPD.Method类的典型用法代码示例。如果您正苦于以下问题:Java Method类的具体用法?Java Method怎么用?Java Method使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Method类属于fi.iki.elonen.NanoHTTPD包,在下文中一共展示了Method类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: get
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Override
public Response get(UriResource uriResource, Map<String, String> urlParams, IHTTPSession session) {
Method method = session.getMethod();
String uri = session.getUri();
//Log.d(TAG, "Method: " + method + ", Url: " + uri);
try {
EpubFetcher fetcher = uriResource.initParameter(EpubFetcher.class);
int offset = uri.indexOf("/", 0);
int startIndex = uri.indexOf("/", offset + 1);
String filePath = uri.substring(startIndex + 1);
Link link = fetcher.publication.getResourceMimeType(filePath);
String mimeType = link.getTypeLink();
InputStream inputStream = fetcher.getDataInputStream(filePath);
response = serveResponse(session, inputStream, mimeType);
} catch (EpubFetcherException e) {
e.printStackTrace();
return NanoHTTPD.newFixedLengthResponse(Status.INTERNAL_ERROR, getMimeType(), ResponseStatus.FAILURE_RESPONSE);
}
return response;
}
开发者ID:codetoart,项目名称:r2-streamer-java,代码行数:24,代码来源:ResourceHandler.java
示例2: testNull
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void testNull() throws Exception {
DataWorldCallableStatement statement = sampleSparqlCallableStatement();
statement.setString("p", "not-null");
statement.setBigDecimal("bigdecimal", null);
statement.setDate("date", null);
statement.setNString("nstring", null);
statement.setNull("null", Types.VARCHAR);
statement.setNull("null2", Types.VARCHAR, "IGNORED");
statement.setObject("object", null);
statement.setObject("object", null, Types.INTEGER);
statement.setObject("object", null, JDBCType.INTEGER);
statement.setString("string", null);
statement.setTime("time", null);
statement.setTimestamp("timestamp", null);
statement.setURL("url", null);
statement.execute();
verify(lastBackendRequest).handle(Method.POST, sparql.urlPath(), null, Utils.TYPE_FORM_URLENCODED, String.join("&",
Utils.queryParam("query", "select ?s ?p ?o where {?s ?p ?o.} limit 10"),
Utils.queryParam("$p", "\"not-null\"")));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:22,代码来源:CallableStatementTest.java
示例3: testNull
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void testNull() throws Exception {
DataWorldPreparedStatement statement = sql.prepareStatement(sql.connect(), "select * from Fielding where yearid in (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
int index = 0;
statement.setString(++index, "not-null");
statement.setBigDecimal(++index, null);
statement.setDate(++index, null);
statement.setNString(++index, null);
statement.setNull(++index, Types.VARCHAR);
statement.setNull(++index, Types.VARCHAR, "IGNORED");
statement.setObject(++index, null);
statement.setObject(++index, null, Types.INTEGER);
statement.setObject(++index, null, JDBCType.INTEGER);
statement.setString(++index, null);
statement.setTime(++index, null);
statement.setTimestamp(++index, null);
statement.setURL(++index, null);
statement.execute();
verify(lastBackendRequest).handle(Method.POST, sql.urlPath(), null, Utils.TYPE_FORM_URLENCODED, String.join("&",
Utils.queryParam("query", "select * from Fielding where yearid in (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"),
Utils.queryParam("$data_world_param0", "\"not-null\"")));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:23,代码来源:PreparedStatementTest.java
示例4: invoke
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
static void invoke(IHTTPSession session, NanoHTTPDHandler handler) {
Method method = session.getMethod();
String urlPath = session.getUri();
String queryParameters = session.getQueryParameterString();
if (method == Method.POST || method == Method.PUT) {
String body = null;
String contentType = session.getHeaders().get("content-type");
String requestLength = session.getHeaders().get("content-length");
if (requestLength != null) {
byte[] bytes = new byte[Integer.parseInt(requestLength)];
try {
IOUtils.readFully(session.getInputStream(), bytes);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
body = new String(bytes, UTF_8);
}
handler.handle(method, urlPath, queryParameters, contentType, body);
} else {
handler.handle(method, urlPath, queryParameters);
}
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:23,代码来源:NanoHTTPDHandler.java
示例5: findRoute
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
public void findRoute() throws Throwable {
JavaServer router = new JavaServer(1020);
RouteMap routeMap;
JSONObject params;
Route route;
route = router.findRoute(Method.GET, "/status");
routeMap = route.getMap();
params = route.getParams();
AssertJUnit.assertEquals(Method.GET, routeMap.getMethod());
AssertJUnit.assertEquals("/status", routeMap.getUri());
route = router.findRoute(Method.GET, "/session/SESSION_ID/element/ELEMENT_ID/size");
routeMap = route.getMap();
params = route.getParams();
AssertJUnit.assertEquals(Method.GET, routeMap.getMethod());
AssertJUnit.assertEquals("/session/:sessionId/element/:id/size", routeMap.getUri());
AssertJUnit.assertEquals("SESSION_ID", params.get("sessionId"));
route = router.findRoute(Method.GET, "/session/SESSION-ID/element/ELEMENT-ID/css/PROPERTY-NAME");
routeMap = route.getMap();
params = route.getParams();
AssertJUnit.assertEquals(Method.GET, routeMap.getMethod());
AssertJUnit.assertEquals("/session/:sessionId/element/:id/css/:propertyName", routeMap.getUri());
AssertJUnit.assertEquals("SESSION-ID", params.get("sessionId"));
AssertJUnit.assertEquals("ELEMENT-ID", params.get("id"));
AssertJUnit.assertEquals("PROPERTY-NAME", params.get("propertyName"));
route = router.findRoute(Method.GET, "/session/SESSION-ID/element/ELEMENT-ID");
routeMap = route.getMap();
params = route.getParams();
AssertJUnit.assertEquals(Method.GET, routeMap.getMethod());
AssertJUnit.assertEquals("/session/:sessionId/element/:id", routeMap.getUri());
AssertJUnit.assertEquals("SESSION-ID", params.get("sessionId"));
AssertJUnit.assertEquals("ELEMENT-ID", params.get("id"));
route = router.findRoute(Method.POST, "/session/SESSION-ID/element/active");
routeMap = route.getMap();
params = route.getParams();
AssertJUnit.assertEquals(Method.POST, routeMap.getMethod());
AssertJUnit.assertEquals("/session/:sessionId/element/active", routeMap.getUri());
AssertJUnit.assertEquals("SESSION-ID", params.get("sessionId"));
}
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:39,代码来源:RouterTest.java
示例6: test
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void test() throws Exception {
resultResourceName = "/select.json";
resultMimeType = Utils.TYPE_SPARQL_RESULTS;
DataWorldStatement statement = sparql.createStatement(sparql.connect());
Utils.dumpToStdout(sparql.executeQuery(statement, "select ?s ?p ?o where{?s ?p ?o.} limit 10"));
verify(lastBackendRequest).handle(Method.POST, sparql.urlPath(), null, Utils.TYPE_FORM_URLENCODED,
Utils.queryParam("query", "select ?s ?p ?o where{?s ?p ?o.} limit 10"));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:11,代码来源:SparqlTest.java
示例7: testAsk
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void testAsk() throws Exception {
resultResourceName = "/ask.json";
resultMimeType = Utils.TYPE_SPARQL_RESULTS;
DataWorldStatement statement = sparql.createStatement(sparql.connect());
Utils.dumpToStdout(sparql.executeQuery(statement, "ask{?s ?p ?o.}"));
verify(lastBackendRequest).handle(Method.POST, sparql.urlPath(), null, Utils.TYPE_FORM_URLENCODED,
Utils.queryParam("query", "ask{?s ?p ?o.}"));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:11,代码来源:SparqlTest.java
示例8: testDescribe
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void testDescribe() throws Exception {
resultResourceName = "/describe.rj";
resultMimeType = Utils.TYPE_RDF_JSON;
DataWorldStatement statement = sparql.createStatement(sparql.connect());
Utils.dumpToStdout(sparql.executeQuery(statement, "DESCRIBE ?s where{?s ?p ?o.} limit 10"));
verify(lastBackendRequest).handle(Method.POST, sparql.urlPath(), null, Utils.TYPE_FORM_URLENCODED,
Utils.queryParam("query", "DESCRIBE ?s where{?s ?p ?o.} limit 10"));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:11,代码来源:SparqlTest.java
示例9: testConstruct
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void testConstruct() throws Exception {
resultResourceName = "/construct.rj";
resultMimeType = Utils.TYPE_RDF_JSON;
DataWorldStatement statement = sparql.createStatement(sparql.connect());
Utils.dumpToStdout(sparql.executeQuery(statement, "Construct{?o ?p ?s} where{?s ?p ?o.} limit 10"));
verify(lastBackendRequest).handle(Method.POST, sparql.urlPath(), null, Utils.TYPE_FORM_URLENCODED,
Utils.queryParam("query", "Construct{?o ?p ?s} where{?s ?p ?o.} limit 10"));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:11,代码来源:SparqlTest.java
示例10: testPrepared
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void testPrepared() throws Exception {
resultResourceName = "/select.json";
resultMimeType = Utils.TYPE_SPARQL_RESULTS;
DataWorldConnection connection = sparql.connect();
DataWorldPreparedStatement statement = sparql.prepareStatement(connection, "select ?s ?p ?o where{?s ?p ?o.} limit 10");
Utils.dumpToStdout(sparql.executeQuery(statement));
verify(lastBackendRequest).handle(Method.POST, sparql.urlPath(), null, Utils.TYPE_FORM_URLENCODED,
Utils.queryParam("query", "select ?s ?p ?o where{?s ?p ?o.} limit 10"));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:12,代码来源:SparqlTest.java
示例11: setBigDecimal
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void setBigDecimal() throws Exception {
DataWorldPreparedStatement statement = samplePreparedStatement();
statement.setBigDecimal(1, new BigDecimal(3));
statement.execute();
verify(lastBackendRequest).handle(eq(Method.POST), eq(sql.urlPath()), isNull(), eq(Utils.TYPE_FORM_URLENCODED),
endsWith(Utils.queryParam("$data_world_param0", "\"3\"^^<http://www.w3.org/2001/XMLSchema#decimal>")));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:9,代码来源:PreparedStatementTest.java
示例12: setBoolean
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void setBoolean() throws Exception {
DataWorldPreparedStatement statement = samplePreparedStatement();
statement.setBoolean(1, true);
statement.execute();
verify(lastBackendRequest).handle(eq(Method.POST), eq(sql.urlPath()), isNull(), eq(Utils.TYPE_FORM_URLENCODED),
endsWith(Utils.queryParam("$data_world_param0", "\"true\"^^<http://www.w3.org/2001/XMLSchema#boolean>")));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:9,代码来源:PreparedStatementTest.java
示例13: setByte
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void setByte() throws Exception {
DataWorldPreparedStatement statement = samplePreparedStatement();
statement.setByte(1, (byte) 4);
statement.execute();
verify(lastBackendRequest).handle(eq(Method.POST), eq(sql.urlPath()), isNull(), eq(Utils.TYPE_FORM_URLENCODED),
endsWith(Utils.queryParam("$data_world_param0", "\"4\"^^<http://www.w3.org/2001/XMLSchema#integer>")));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:9,代码来源:PreparedStatementTest.java
示例14: setDate
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void setDate() throws Exception {
DataWorldPreparedStatement statement = samplePreparedStatement();
statement.setDate(1, new Date(1477433443000L));
statement.execute();
verify(lastBackendRequest).handle(eq(Method.POST), eq(sql.urlPath()), isNull(), eq(Utils.TYPE_FORM_URLENCODED),
endsWith(Utils.queryParam("$data_world_param0", "\"2016-10-25\"^^<http://www.w3.org/2001/XMLSchema#date>")));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:9,代码来源:PreparedStatementTest.java
示例15: setDouble
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void setDouble() throws Exception {
DataWorldPreparedStatement statement = samplePreparedStatement();
statement.setDouble(1, 3.0);
statement.execute();
verify(lastBackendRequest).handle(eq(Method.POST), eq(sql.urlPath()), isNull(), eq(Utils.TYPE_FORM_URLENCODED),
endsWith(Utils.queryParam("$data_world_param0", "\"3.0\"^^<http://www.w3.org/2001/XMLSchema#decimal>")));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:9,代码来源:PreparedStatementTest.java
示例16: setFloat
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void setFloat() throws Exception {
DataWorldPreparedStatement statement = samplePreparedStatement();
statement.setFloat(1, 3.0F);
statement.execute();
verify(lastBackendRequest).handle(eq(Method.POST), eq(sql.urlPath()), isNull(), eq(Utils.TYPE_FORM_URLENCODED),
endsWith(Utils.queryParam("$data_world_param0", "\"3.0\"^^<http://www.w3.org/2001/XMLSchema#decimal>")));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:9,代码来源:PreparedStatementTest.java
示例17: setInt
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void setInt() throws Exception {
DataWorldPreparedStatement statement = samplePreparedStatement();
statement.setInt(1, 3);
statement.execute();
verify(lastBackendRequest).handle(eq(Method.POST), eq(sql.urlPath()), isNull(), eq(Utils.TYPE_FORM_URLENCODED),
endsWith(Utils.queryParam("$data_world_param0", "\"3\"^^<http://www.w3.org/2001/XMLSchema#integer>")));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:9,代码来源:PreparedStatementTest.java
示例18: setLong
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void setLong() throws Exception {
DataWorldPreparedStatement statement = samplePreparedStatement();
statement.setLong(1, 3L);
statement.execute();
verify(lastBackendRequest).handle(eq(Method.POST), eq(sql.urlPath()), isNull(), eq(Utils.TYPE_FORM_URLENCODED),
endsWith(Utils.queryParam("$data_world_param0", "\"3\"^^<http://www.w3.org/2001/XMLSchema#integer>")));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:9,代码来源:PreparedStatementTest.java
示例19: setNString
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void setNString() throws Exception {
DataWorldPreparedStatement statement = samplePreparedStatement();
statement.setNString(1, "foo");
statement.execute();
verify(lastBackendRequest).handle(eq(Method.POST), eq(sql.urlPath()), isNull(), eq(Utils.TYPE_FORM_URLENCODED),
endsWith(Utils.queryParam("$data_world_param0", "\"foo\"")));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:9,代码来源:PreparedStatementTest.java
示例20: setNull
import fi.iki.elonen.NanoHTTPD.Method; //导入依赖的package包/类
@Test
public void setNull() throws Exception {
DataWorldPreparedStatement statement = samplePreparedStatement();
statement.setNull(1, Types.VARCHAR);
statement.execute();
verify(lastBackendRequest).handle(Method.POST, sql.urlPath(), null, Utils.TYPE_FORM_URLENCODED,
Utils.queryParam("query", "select * from Fielding where yearid = ?"));
}
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:9,代码来源:PreparedStatementTest.java
注:本文中的fi.iki.elonen.NanoHTTPD.Method类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论