当前位置: 首页>>代码示例>>Java>>正文


Java HttpClientRequest类代码示例

本文整理汇总了Java中org.vertx.java.core.http.HttpClientRequest的典型用法代码示例。如果您正苦于以下问题:Java HttpClientRequest类的具体用法?Java HttpClientRequest怎么用?Java HttpClientRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpClientRequest类属于org.vertx.java.core.http包,在下文中一共展示了HttpClientRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doRequest

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
@Override
protected void doRequest(final HttpClient client) {

    // Build query URI
    StringBuilder queryUri = new StringBuilder(m_query);
    queryUri.append(API_KEY_TOKEN);
    queryUri.append(m_token);

    m_logger.trace("Executing query: {} (host: {})",
            queryUri, getConnection().getAddress());

    HttpClientRequest request = doGet(queryUri.toString(), m_handler);
    request.exceptionHandler(new DefaultConnectionExceptionHandler(
            getConnection()));
    request.end();
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:17,代码来源:Ubidots.java

示例2: refreshToken

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
public void refreshToken(final Handler<Boolean> handler){
	HttpClientRequest req = cursusClient.post(wsEndpoint.getPath() + "/AuthentificationImpl.svc/json/AuthentificationExtranet", new Handler<HttpClientResponse>() {
		public void handle(HttpClientResponse response) {
			if(response.statusCode() >= 300){
				handler.handle(false);
				log.error(response.statusMessage());
				return;
			}

			response.bodyHandler(new Handler<Buffer>() {
				public void handle(Buffer body) {
					log.info("[Cursus][refreshToken] Token refreshed.");

					JsonObject authData = new JsonObject(body.toString());
					authData.putNumber("tokenInit", new Date().getTime());
					cursusMap.put("auth", authData.encode());
					handler.handle(true);
				}
			});
		}
	});
	req.putHeader(HttpHeaders.ACCEPT, "application/json; charset=UTF-8")
	   .putHeader(HttpHeaders.CONTENT_TYPE, "application/json");
	req.end(authConf.encode());
}
 
开发者ID:OPEN-ENT-NG,项目名称:cursus,代码行数:26,代码来源:CursusController.java

示例3: processMessage

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
private void processMessage(final HttpServerRequest request, SoapHelper.SoapDescriptor messageDescriptor){
	String xml = "";
	try {
		xml = SoapHelper.createSoapMessage(messageDescriptor);
	} catch (SOAPException | IOException e) {
		log.error("["+MaxicoursController.class.getSimpleName()+"]("+messageDescriptor.getBodyTagName()+") Error while building the soap request.");
		renderError(request);
		return;
	}

	HttpClientRequest req = soapClient.post(soapEndpoint.getPath(), new Handler<HttpClientResponse>() {
		public void handle(final HttpClientResponse response) {
			response.bodyHandler(new Handler<Buffer>() {
				@Override
				public void handle(Buffer body) {
					request.response().end(body);
				}
			});
		}
	});
	req
		.putHeader("SOAPAction", messageDescriptor.getBodyTag())
		.putHeader(HttpHeaders.CONTENT_TYPE, "text/xml;charset=UTF-8");
	req.end(xml);
}
 
开发者ID:OPEN-ENT-NG,项目名称:aide-aux-devoirs,代码行数:26,代码来源:MaxicoursController.java

示例4: getSimpleConnection

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
@Test
@Ignore

public void getSimpleConnection() throws InterruptedException, IOException {
    CountDownLatch latch = new CountDownLatch(1);
    CountDownLatch latch2 = new CountDownLatch(1);
    HttpClient client = getClient();
    HttpClientRequest request = client.get("/employee", new Handler<HttpClientResponse>() {
        public void handle(HttpClientResponse resp) {
             resp.bodyHandler(body->System.out.println("Got a response: " +body.toString()));
            latch.countDown();
        }
    });

    request.end();
    latch.await();



}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:21,代码来源:RestEntryVerticleTest.java

示例5: testSimpleRESTGETWithParameterPath

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
@Test
public  void testSimpleRESTGETWithParameterPath() throws InterruptedException, MalformedURLException {
    connectMain(1);
    CountDownLatch latch = new CountDownLatch(1);


    HttpClientRequest request = getClient().get("/service-REST-GET/testEmployeeFour/123/employee/andy", new Handler<HttpClientResponse>() {
        public void handle(HttpClientResponse resp) {
            resp.bodyHandler(body -> {System.out.println("Got a response: " + body.toString());
                Assert.assertEquals(body.toString(), "123:andy");});

            latch.countDown();
        }
    });

    request.end();
    latch.await();
}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:19,代码来源:RestGetTest.java

示例6: testSimpleRESTGETWithParameterPath2

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
@Test
public  void testSimpleRESTGETWithParameterPath2() throws InterruptedException, MalformedURLException {
    connectMain(1);
    CountDownLatch latch = new CountDownLatch(1);


    HttpClientRequest request = getClient().get("/service-REST-GET/testEmployeeThree/456/andy", new Handler<HttpClientResponse>() {
        public void handle(HttpClientResponse resp) {
            resp.bodyHandler(body -> {System.out.println("Got a response: " + body.toString());
                Assert.assertEquals(body.toString(), "456:andy");});

            latch.countDown();
        }
    });

    request.end();
    latch.await();
}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:19,代码来源:RestGetTest.java

示例7: testSimpleRESTGETWithParameterPathError

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
@Test
public  void testSimpleRESTGETWithParameterPathError() throws InterruptedException, MalformedURLException {
    connectMain(1);
    CountDownLatch latch = new CountDownLatch(1);


    HttpClientRequest request = getClient().get("/service-REST-GET/testEmployeeFour/123/andy", new Handler<HttpClientResponse>() {
        public void handle(HttpClientResponse resp) {
            resp.bodyHandler(body -> {System.out.println("Got a response: " + body.toString());
                Assert.assertEquals(body.toString(), "no route found");});

            latch.countDown();
        }
    });

    request.end();
    latch.await();
}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:19,代码来源:RestGetTest.java

示例8: testSimpleRESTGETWithQueryParameter

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
@Test
public  void testSimpleRESTGETWithQueryParameter() throws InterruptedException, MalformedURLException {
    connectMain(1);
    CountDownLatch latch = new CountDownLatch(1);


    HttpClientRequest request = getClient().get("/service-REST-GET/testEmployeeOne?name=789&lastname=andy", new Handler<HttpClientResponse>() {
        public void handle(HttpClientResponse resp) {
            resp.bodyHandler(body -> {System.out.println("Got a response: " + body.toString());
                Assert.assertEquals(body.toString(), "789:andy");});

            latch.countDown();
        }
    });

    request.end();
    latch.await();
}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:19,代码来源:RestGetTest.java

示例9: testSimpleRESTGETWithQueryParameterAndReturnValue

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
@Test
public  void testSimpleRESTGETWithQueryParameterAndReturnValue() throws InterruptedException, MalformedURLException {
    connectMain(1);
    CountDownLatch latch = new CountDownLatch(1);


    HttpClientRequest request = getClient().get("/service-REST-GET/testEmployeeTwo?id=123", new Handler<HttpClientResponse>() {
        public void handle(HttpClientResponse resp) {
            resp.bodyHandler(body -> {System.out.println("Got a response123: " + body.toString());
                Assert.assertEquals(body.toString(), "{\n" +
                        "  \"id\" : \"123\"\n" +
                        "}");});

            latch.countDown();
        }
    });

    request.end();
    latch.await();
}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:21,代码来源:RestGetTest.java

示例10: testSimpleRESTGETWithQueryParameterAndObjectReturnValue

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
@Test
public  void testSimpleRESTGETWithQueryParameterAndObjectReturnValue() throws InterruptedException, MalformedURLException {
    connectMain(1);
    CountDownLatch latch = new CountDownLatch(1);


    HttpClientRequest request = getClient().get("/service-REST-GET/testEmployeeFive?id=123", new Handler<HttpClientResponse>() {
        public void handle(HttpClientResponse resp) {
            resp.bodyHandler(body -> {System.out.println("Got a response123: " + body.toString());
                Assert.assertEquals(body.toString(), "{\"employeeId\":\"fg\",\"jobDescription\":\"dfg\",\"jobType\":\"dfg\",\"firstName\":\"fdg\",\"lastName\":\"dfg\"}");});

            latch.countDown();
        }
    });

    request.end();
    latch.await();
}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:19,代码来源:RestGetTest.java

示例11: httpPost

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
/**
 * Performs a HTTP POST request on the specified address, using the body parameter for the request body
 * 
 * @param persistor instance of the RestPersistor
 * @param apiPath URL path to use for the request
 * @param headers optional headers to set in the request
 * @param body the JSON document to send in the body of the request
 * @param timeout timeout for the HTTP connection
 * @param msg the Vertx Message object to which the error message can be send
 */
protected void httpPost(ArangoPersistor persistor, String apiPath, JsonObject headers, JsonObject body, int timeout, Message<JsonObject> msg) {
    // launch the request
    HttpClientRequest clientRequest = persistor.getClient().post(apiPath, new RestResponseHandler(msg, logger, helper));
    
    // set headers
    clientRequest = addRequestHeaders(clientRequest, persistor, headers);
    // set content-length before we write the body !
    clientRequest.putHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(body.toString().length()));
    
    // write the body
    clientRequest.write(body.toString());
    
    // end the request
    clientRequest.setTimeout(timeout).end();
}
 
开发者ID:santo74,项目名称:vertx-arangodb,代码行数:26,代码来源:AbstractRestAPI.java

示例12: httpPut

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
/**
 * Performs a HTTP PUT request on the specified address, using the body parameter for the request body
 * 
 * @param persistor instance of the RestPersistor
 * @param apiPath URL path to use for the request
 * @param headers optional headers to set in the request
 * @param body the JSON document to send in the body of the request
 * @param timeout timeout for the HTTP connection
 * @param msg the Vertx Message object to which the error message can be send
 */
protected void httpPut(ArangoPersistor persistor, String apiPath, JsonObject headers, JsonObject body, int timeout, Message<JsonObject> msg) {
    // launch the request
    HttpClientRequest clientRequest = persistor.getClient().put(apiPath, new RestResponseHandler(msg, logger, helper));
    
    // set Headers and end the request
    addRequestHeaders(clientRequest, persistor, headers);
    
    if (body != null) {
    // set content-length before we write the body !
        clientRequest.putHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(body.toString().length()));
        // write the body
        clientRequest.write(body.toString());
    }
    
    // end the request
    clientRequest.setTimeout(timeout).end();        
}
 
开发者ID:santo74,项目名称:vertx-arangodb,代码行数:28,代码来源:AbstractRestAPI.java

示例13: httpPatch

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
/**
 * Performs a HTTP PATCH request on the specified address, using the body parameter for the request body
 * 
 * @param persistor instance of the RestPersistor
 * @param apiPath URL path to use for the request
 * @param headers optional headers to set in the request
 * @param body the JSON document to send in the body of the request
 * @param timeout timeout for the HTTP connection
 * @param msg the Vertx Message object to which the error message can be send
 */
protected void httpPatch(ArangoPersistor persistor, String apiPath, JsonObject headers, JsonObject body, int timeout, Message<JsonObject> msg) {
    // launch the request
    HttpClientRequest clientRequest = persistor.getClient().patch(apiPath, new RestResponseHandler(msg, logger, helper));
    
    // set headers
    clientRequest = addRequestHeaders(clientRequest, persistor, headers);
    // set content-length before we write the body !
    clientRequest.putHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(body.toString().length()));
    
    // write the body
    clientRequest.write(body.toString());
    
    // end the request
    clientRequest.setTimeout(timeout).end();        
}
 
开发者ID:santo74,项目名称:vertx-arangodb,代码行数:26,代码来源:AbstractRestAPI.java

示例14: sendFile

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
public static void sendFile(Vertx vertx, String uri, int port, String content,
		MultiMap headers, String filename,
		String contentType, Handler<HttpClientResponse> handler) {
	HttpClientRequest req = vertx.createHttpClient().setPort(port).post(uri, handler);

	final String boundary = "dLV9Wyq26L_-JQxk6ferf-RT153LhOO";
	Buffer buffer = new Buffer();
	final String body = "--" + boundary + "\r\n" +
			"Content-Disposition: form-data; name=\"file\"; filename=\""+ filename +"\"\r\n" +
			"Content-Type: " + contentType + "\r\n" +
			"\r\n" +
			content + "\r\n" +
			"--" + boundary + "--\r\n";

	buffer.appendString(body);
	req.headers().add(headers);
	req.headers().set("content-length", String.valueOf(buffer.length()));
	req.headers().set("content-type", "multipart/form-data; boundary=" + boundary);
	req.write(buffer).end();
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:21,代码来源:HttpClientUtils.java

示例15: createIndex

import org.vertx.java.core.http.HttpClientRequest; //导入依赖的package包/类
private void createIndex(final JsonObject j) {
	try {
		final HttpClientRequest req = nodeManager.getClient()
				.post("/db/data/index/" + j.getString("for"), new Handler<HttpClientResponse>() {
			@Override
			public void handle(HttpClientResponse event) {
				if (event.statusCode() != 200) {
					logger.error("Error creating index " + j.encode());
				}
			}
		});
		JsonObject body = new JsonObject().putString("name", j.getString("name"));
		body.putObject("config", new JsonObject()
				.putString("type", j.getString("type", "exact"))
				.putString("provider", "lucene"));
		req.end(body.encode());
	} catch (Neo4jConnectionException e) {
		logger.error(e.getMessage(), e);
	}
}
 
开发者ID:web-education,项目名称:mod-neo4j-persistor,代码行数:21,代码来源:Neo4jRest.java


注:本文中的org.vertx.java.core.http.HttpClientRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。