本文整理汇总了Java中org.eclipse.jetty.http.HttpMethod类的典型用法代码示例。如果您正苦于以下问题:Java HttpMethod类的具体用法?Java HttpMethod怎么用?Java HttpMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpMethod类属于org.eclipse.jetty.http包,在下文中一共展示了HttpMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initClientProxy
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
private void initClientProxy() {
int port = Context.getConfig().getInteger("osmand.port");
if (port != 0) {
ServletContextHandler servletHandler = new ServletContextHandler() {
@Override
public void doScope(
String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (target.equals("/") && request.getMethod().equals(HttpMethod.POST.asString())) {
super.doScope(target, baseRequest, request, response);
}
}
};
ServletHolder servletHolder = new ServletHolder(new AsyncProxyServlet.Transparent());
servletHolder.setInitParameter("proxyTo", "http://localhost:" + port);
servletHandler.addServlet(servletHolder, "/");
handlers.addHandler(servletHandler);
}
}
示例2: testRetry
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
@Test
public void testRetry() throws Exception {
SalesforceComponent sf = context().getComponent("salesforce", SalesforceComponent.class);
String accessToken = sf.getSession().getAccessToken();
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setSslContext(new SSLContextParameters().createSSLContext(context));
HttpClient httpClient = new HttpClient(sslContextFactory);
httpClient.setConnectTimeout(60000);
httpClient.start();
String uri = sf.getLoginConfig().getLoginUrl() + "/services/oauth2/revoke?token=" + accessToken;
Request logoutGet = httpClient.newRequest(uri)
.method(HttpMethod.GET)
.timeout(1, TimeUnit.MINUTES);
ContentResponse response = logoutGet.send();
assertEquals(HttpStatus.OK_200, response.getStatus());
JobInfo jobInfo = new JobInfo();
jobInfo.setOperation(OperationEnum.INSERT);
jobInfo.setContentType(ContentType.CSV);
jobInfo.setObject(Merchandise__c.class.getSimpleName());
createJob(jobInfo);
}
示例3: getQRCode
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
/**
* 获取二维码
*
* @return 二维码图片的内容
* @throws InterruptedException
* if send thread is interrupted
* @throws ExecutionException
* if execution fails
* @throws TimeoutException
* if send times out
*/
// 登录流程1:获取二维码
public byte[] getQRCode() throws InterruptedException, ExecutionException, TimeoutException {
LOGGER.debug("开始获取二维码");
ContentResponse response = httpClient.newRequest(ApiURL.GET_QR_CODE.getUrl()).timeout(10, TimeUnit.SECONDS)
.method(HttpMethod.GET).agent(ApiURL.USER_AGENT).send();
byte[] imageBytes = response.getContent();
List<HttpCookie> httpCookieList = httpClient.getCookieStore().get(response.getRequest().getURI());
for (HttpCookie httpCookie : httpCookieList) {
if ("qrsig".equals(httpCookie.getName())) {
this.qrsig = httpCookie.getValue();
break;
}
}
LOGGER.debug("二维码已获取");
return imageBytes;
}
示例4: postRequest
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
private Request postRequest(ApiURL url, JsonObject r, Timeout timeout) {
Fields fields = new Fields();
fields.add("r", GsonUtil.gson.toJson(r));
Request request = httpClient.newRequest(url.getUrl()).method(HttpMethod.POST).agent(ApiURL.USER_AGENT)
.header("Origin", url.getOrigin()).content(new FormContentProvider(fields));
if (url.getReferer() != null) {
request.header(HttpHeader.REFERER, url.getReferer());
}
if (timeout != null) {
request.timeout(timeout.getTime(), timeout.getUnit());
}
return request;
}
示例5: shouldCreateCounters
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
@Test
public void shouldCreateCounters() {
for (int responseStatus = 1; responseStatus <= 5; responseStatus++) {
assertThat(registry.getKeys("jetty.Response.Invocations")).contains(responseStatus + "xx-responses");
assertThat(registry.getKeys("jetty.Response.Durations")).contains(responseStatus + "xx-responses");
}
assertThat(registry.getKeys("jetty.Response.Invocations")).contains("other-responses");
assertThat(registry.getKeys("jetty.Response.Durations")).contains("other-responses");
for (HttpMethod method : HttpMethod.values()) {
String name = method.asString().toLowerCase();
assertThat(registry.getKeys("jetty.Request.Invocations")).contains(name + "-requests");
assertThat(registry.getKeys("jetty.Request.Durations")).contains(name + "-requests");
}
assertThat(registry.getKeys("jetty.Request.Invocations")).contains("other-requests");
assertThat(registry.getKeys("jetty.Request.Durations")).contains("other-requests");
assertThat(registry.getKeys("jetty.Aggregated.Invocations")).contains("requests");
assertThat(registry.getKeys("jetty.Aggregated.Durations")).contains("requests");
}
示例6: shouldInitializeCounters
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
@Test
public void shouldInitializeCounters() {
for (int responseStatus = 1; responseStatus <= 5; responseStatus++) {
assertThat(registry.get("jetty.Response.Invocations", responseStatus + "xx-responses")).isEqualTo(0);
assertThat(registry.get("jetty.Response.Durations", responseStatus + "xx-responses")).isEqualTo(0);
}
assertThat(registry.get("jetty.Response.Invocations", "other-responses")).isEqualTo(0);
assertThat(registry.get("jetty.Response.Durations", "other-responses")).isEqualTo(0);
for (HttpMethod method : HttpMethod.values()) {
String name = method.asString().toLowerCase();
assertThat(registry.get("jetty.Request.Invocations", name + "-requests")).isEqualTo(0);
assertThat(registry.get("jetty.Request.Durations", name + "-requests")).isEqualTo(0);
}
assertThat(registry.get("jetty.Request.Invocations", "other-requests")).isEqualTo(0);
assertThat(registry.get("jetty.Request.Durations", "other-requests")).isEqualTo(0);
assertThat(registry.get("jetty.Aggregated.Invocations", "requests")).isEqualTo(0);
assertThat(registry.get("jetty.Aggregated.Durations", "requests")).isEqualTo(0);
}
示例7: getQueryResultIds
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
@Override
public void getQueryResultIds(String jobId, String batchId, final QueryResultIdsCallback callback) {
final Request get = getRequest(HttpMethod.GET, batchResultUrl(jobId, batchId, null));
// make the call and parse the result
doHttpRequest(get, new ClientResponseCallback() {
@Override
public void onResponse(InputStream response, SalesforceException ex) {
QueryResultList value = null;
try {
value = unmarshalResponse(response, get, QueryResultList.class);
} catch (SalesforceException e) {
ex = e;
}
callback.onResponse(value != null ? Collections.unmodifiableList(value.getResult()) : null, ex);
}
});
}
示例8: addStaticResourceConfig
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
private void addStaticResourceConfig(ServletContextHandler context) {
URL webappLocation = getClass().getResource("/webapp/index.html");
if (webappLocation == null) {
System.err.println("Couldn't get webapp location.");
} else {
try {
URI webRootUri = URI.create(webappLocation.toURI().toASCIIString().replaceFirst("/index.html$", "/"));
context.setBaseResource(Resource.newResource(webRootUri));
context.setWelcomeFiles(new String[]{"index.html"});
GzipHandler gzipHandler = new GzipHandler();
gzipHandler.setIncludedMethods(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name());
context.setGzipHandler(gzipHandler);
context.addFilter(TryFilesFilter.class, "*", EnumSet.of(DispatcherType.REQUEST));
} catch (URISyntaxException | MalformedURLException e) {
e.printStackTrace();
}
}
}
示例9: rawRequest
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
protected String rawRequest(String url, Map<String, String> params) throws InterruptedException, ExecutionException, TimeoutException, UnsupportedEncodingException {
Request req = httpClient.newRequest(new String(url.getBytes("UTF-8"), "UTF-8"))
.header(HttpHeader.CONTENT_ENCODING, "UTF-8")
.method(HttpMethod.GET)
.header(HttpHeader.ACCEPT_ENCODING, "UTF-8");
req = req.param("app_token", APIKeys.getAPPKey());
if (params != null) {
for (String key : params.keySet()) {
req = req.param(key, params.get(key));
}
}
Main.log.info("GET {}, {}, {}", req, req.getQuery(), req.getParams());
ContentResponse resp = req.send();
if (resp.getStatus() != HttpStatus.OK_200) {
throw new HttpRequestException(
"Request ended with non-OK status: "
+ HttpStatus.getMessage(resp.getStatus()),
resp.getRequest()
);
}
return resp.getContentAsString();
}
示例10: doExecuteRequest
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
@Override
protected RemoteInvocationResult doExecuteRequest(
HttpInvokerClientConfiguration config, ByteArrayOutputStream baos)
throws Exception {
if (this.connectTimeout >= 0) {
httpClient.setConnectTimeout(this.connectTimeout);
}
if (this.readTimeout >= 0) {
httpClient.setIdleTimeout(this.readTimeout);
}
ContentResponse response = httpClient.newRequest(config.getServiceUrl())
.method(HttpMethod.POST)
.content(new BytesContentProvider(baos.toByteArray()))
.send();
if (response.getStatus() >= 300) {
throw new IOException(
"Did not receive successful HTTP response: status code = " + response.getStatus() +
", status message = [" + response.getReason() + "]");
}
return readRemoteInvocationResult(new ByteArrayInputStream(response.getContent()), config.getCodebaseUrl());
}
示例11: getJails
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
@Endpoint(method = HttpMethod.GET, path = "jail", perm = "jail.list")
public void getJails(IServletData data) {
Optional<NucleusJailService> optSrv = NucleusAPI.getJailService();
if (!optSrv.isPresent()) {
data.sendError(HttpServletResponse.SC_NOT_FOUND, "Nuclues jail service not available");
return;
}
NucleusJailService srv = optSrv.get();
Optional<List<CachedNamedLocation>> optRes = WebAPIAPI.runOnMain(
() -> srv.getJails().values().stream().map(CachedNamedLocation::new).collect(Collectors.toList())
);
data.addData("ok", optRes.isPresent(), false);
data.addData("jails", optRes.orElse(null), data.getQueryParam("details").isPresent());
}
示例12: getJail
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
@Endpoint(method = HttpMethod.GET, path = "jail/:name", perm = "jail.one")
public void getJail(IServletData data, String name) {
Optional<NucleusJailService> optSrv = NucleusAPI.getJailService();
if (!optSrv.isPresent()) {
data.sendError(HttpServletResponse.SC_NOT_FOUND, "Nuclues jail service not available");
return;
}
NucleusJailService srv = optSrv.get();
Optional<CachedNamedLocation> optRes = WebAPIAPI.runOnMain(() -> {
Optional<NamedLocation> optJail = srv.getJail(name);
if (!optJail.isPresent()) {
data.sendError(HttpServletResponse.SC_NOT_FOUND, "Jail not found");
return null;
}
return new CachedNamedLocation(optJail.get());
});
data.addData("ok", optRes.isPresent(), false);
data.addData("jail", optRes.orElse(null), true);
}
示例13: deleteJail
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
@Endpoint(method = HttpMethod.DELETE, path = "jail/:name", perm = "jail.delete")
public void deleteJail(IServletData data, String name) {
Optional<NucleusJailService> optSrv = NucleusAPI.getJailService();
if (!optSrv.isPresent()) {
data.sendError(HttpServletResponse.SC_NOT_FOUND, "Nuclues jail service not available");
return;
}
NucleusJailService srv = optSrv.get();
Optional<CachedNamedLocation> optRes = WebAPIAPI.runOnMain(() -> {
Optional<NamedLocation> optJail = srv.getJail(name);
if (!optJail.isPresent()) {
data.sendError(HttpServletResponse.SC_NOT_FOUND, "Jail not found");
return null;
}
srv.removeJail(name);
return new CachedNamedLocation(optJail.get());
});
data.addData("ok", optRes.isPresent(), false);
data.addData("jail", optRes.orElse(null), true);
}
示例14: getKits
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
@Endpoint(method = HttpMethod.GET, path = "kit", perm = "kit.list")
public void getKits(IServletData data) {
Optional<NucleusKitService> optSrv = NucleusAPI.getKitService();
if (!optSrv.isPresent()) {
data.sendError(HttpServletResponse.SC_NOT_FOUND, "Nuclues kit service not available");
return;
}
NucleusKitService srv = optSrv.get();
Optional<List<CachedKit>> kits = WebAPIAPI.runOnMain(
() -> srv.getKitNames().stream()
.map(name -> srv.getKit(name).map(CachedKit::new).orElse(null))
.collect(Collectors.toList())
);
data.addData("ok", kits.isPresent(), false);
data.addData("kits", kits.orElse(null), data.getQueryParam("details").isPresent());
}
示例15: getKit
import org.eclipse.jetty.http.HttpMethod; //导入依赖的package包/类
@Endpoint(method = HttpMethod.GET, path = "kit/:name", perm = "kit.one")
public void getKit(IServletData data, String name) {
Optional<NucleusKitService> optSrv = NucleusAPI.getKitService();
if (!optSrv.isPresent()) {
data.sendError(HttpServletResponse.SC_NOT_FOUND, "Nuclues kit service not available");
return;
}
NucleusKitService srv = optSrv.get();
Optional<CachedKit> optRes = WebAPIAPI.runOnMain(() -> {
Optional<Kit> optKit = srv.getKit(name);
if (!optKit.isPresent()) {
data.sendError(HttpServletResponse.SC_NOT_FOUND, "Kit not found");
return null;
}
return new CachedKit(optKit.get());
});
data.addData("ok", optRes.isPresent(), false);
data.addData("kit", optRes.orElse(null), true);
}