org.apache.http.client.fluent.Request.bodyForm()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(238)

本文整理了Java中org.apache.http.client.fluent.Request.bodyForm方法的一些代码示例,展示了Request.bodyForm的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.bodyForm方法的具体详情如下:
包路径:org.apache.http.client.fluent.Request
类名称:Request
方法名:bodyForm

Request.bodyForm介绍

暂无

代码示例

代码示例来源:origin: jooby-project/jooby

public Response expect(final String content) throws Exception {
 if (parts != null) {
  req.req.body(parts.build());
 } else {
  req.req.bodyForm(fields);
 }
 return req.expect(content);
}

代码示例来源:origin: jooby-project/jooby

public Response expect(final int status) throws Exception {
 if (parts != null) {
  req.req.body(parts.build());
 } else {
  req.req.bodyForm(fields);
 }
 return req.expect(status);
}

代码示例来源:origin: dreamhead/moco

@Override
  public void run() throws Exception {
    org.apache.http.client.fluent.Request request = Post(root()).bodyForm(of(new BasicNameValuePair("name", "表单")), Charset.forName("GBK"));
    assertThat(helper.executeAsString(request), is("foobar"));
  }
});

代码示例来源:origin: dreamhead/moco

@Override
  public void run() throws Exception {
    org.apache.http.client.fluent.Request request = Post(root()).bodyForm(new BasicNameValuePair("name", "dreamhead"));
    assertThat(helper.executeAsString(request), is("foobar"));
  }
});

代码示例来源:origin: dreamhead/moco

@Override
  public void run() throws Exception {
    Request request = Request.Post(root()).bodyForm(new BasicNameValuePair("name", "dreamhead"));
    String content = helper.executeAsString(request);
    assertThat(content, is("foobar"));
  }
});

代码示例来源:origin: dreamhead/moco

@Override
  public void run() throws Exception {
    Request request = Request.Post(root()).bodyForm(new BasicNameValuePair("name", "dreamhead"));
    String content = helper.executeAsString(request);
    assertThat(content, is("foobar"));
  }
});

代码示例来源:origin: dreamhead/moco

@Override
  public void run() throws IOException {
    Request request = Request.Post(remoteUrl("/template")).bodyForm(new BasicNameValuePair("name", "dreamhead"));
    assertThat(helper.executeAsString(request), is("dreamhead"));
  }
});

代码示例来源:origin: dreamhead/moco

@Test
public void should_match_form_value() throws IOException {
  runWithConfiguration("form.json");
  Request request = Request.Post(root()).bodyForm(new BasicNameValuePair("name", "dreamhead"));
  assertThat(helper.executeAsString(request), is("foobar"));
}

代码示例来源:origin: dreamhead/moco

@Test
public void should_return_form_value_from_template() throws IOException {
  runWithConfiguration("template.json");
  Request request = Request.Post(remoteUrl("/form_template")).bodyForm(new BasicNameValuePair("foo", "dreamhead"));
  assertThat(helper.executeAsString(request), is("dreamhead"));
}

代码示例来源:origin: org.apache.httpcomponents/fluent-hc

public Request bodyForm(final Iterable <? extends NameValuePair> formParams) {
  return bodyForm(formParams, Consts.ISO_8859_1);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

public Request bodyForm(final Iterable <? extends NameValuePair> formParams) {
  return bodyForm(formParams, Consts.ISO_8859_1);
}

代码示例来源:origin: org.apache.httpcomponents/fluent-hc

public Request bodyForm(final NameValuePair... formParams) {
  return bodyForm(Arrays.asList(formParams), Consts.ISO_8859_1);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

public Request bodyForm(final NameValuePair... formParams) {
  return bodyForm(Arrays.asList(formParams), Consts.ISO_8859_1);
}

代码示例来源:origin: org.streampipes/streampipes-connect

public static String requestProbabilitiesString(Object[] objects) {
  String httpRequestBody = GsonSerializer.getGsonWithIds()
        .toJson(objects);
  String httpResp = "{\"result\": []}";
  try {
    httpResp = Request.Post("http://localhost:" + port +"/predict")
          .addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
          .bodyForm(Form.form().add("X", httpRequestBody).build()).execute().returnContent().asString();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return httpResp;
}

代码示例来源:origin: streampipes/streampipes-ce

public static String requestProbabilitiesString(Object[] objects) {
  String httpRequestBody = GsonSerializer.getGsonWithIds()
        .toJson(objects);
  String httpResp = "{\"result\": []}";
  try {
    httpResp = Request.Post("http://localhost:" + port +"/predict")
          .addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
          .bodyForm(Form.form().add("X", httpRequestBody).build()).execute().returnContent().asString();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return httpResp;
}

代码示例来源:origin: streampipes/streampipes-ce

public boolean installDataSource(String requestUrl, String elementIdUrl) throws AdapterException {
  try {
    String responseString = Request.Post(requestUrl)
        .bodyForm(
            Form.form()
                .add("uri", elementIdUrl)
                .add("publicElement", "true").build())
        .connectTimeout(1000)
        .socketTimeout(100000)
        .execute().returnContent().asString();
    logger.info(responseString);
  } catch (IOException e) {
    logger.error("Error while installing data source: " + requestUrl, e);
    throw new AdapterException();
  }
  return true;
}

代码示例来源:origin: edu.jhuapl.dorset/dorset-core

private Response put(HttpRequest request) throws IOException {
  Request apacheRequest = Request.Put(request.getUrl());
  if (request.getBody() != null) {
    ContentType ct = ContentType.create(request.getContentType().getMimeType(),
            request.getContentType().getCharset());
    apacheRequest.bodyString(request.getBody(), ct);
  } else if (request.getBodyForm() != null) {
    apacheRequest.bodyForm(buildFormBody(request.getBodyForm()));
  }
  prepareRequest(apacheRequest);
  return apacheRequest.execute();
}

代码示例来源:origin: edu.jhuapl.dorset/dorset-core

private Response post(HttpRequest request) throws IOException {
  Request apacheRequest = Request.Post(request.getUrl());
  if (request.getBody() != null) {
    ContentType ct = ContentType.create(request.getContentType().getMimeType(),
            request.getContentType().getCharset());
    apacheRequest.bodyString(request.getBody(), ct);
  } else if (request.getBodyForm() != null) {
    apacheRequest.bodyForm(buildFormBody(request.getBodyForm()));
  }
  prepareRequest(apacheRequest);
  return apacheRequest.execute();
}

代码示例来源:origin: denger/sendcloud4j

private String requestSend(String uri, Email email) throws IOException {
  Request request = Request.Post(uri)
      .connectTimeout(connectTimeout)
      .socketTimeout(socketTimeout);
  if (proxy != null) {
    request.viaProxy(proxy);
  }
  if (email.hasAttachment()) {
    request.body(getMultipartEmailHttpEntity(email));
  } else {
    request.bodyForm(convertFrom(email.getParameters()).build(), UTF_8);
  }
  return request.execute().returnContent().asString(UTF_8);
}

代码示例来源:origin: denger/sendcloud4j

private String requestSend(String uri, Email email) throws IOException {
  Request request = Request.Post(uri)
      .connectTimeout(connectTimeout)
      .socketTimeout(socketTimeout);
  if (proxy != null) {
    request.viaProxy(proxy);
  }
  if (email.hasAttachment()) {
    request.body(getMultipartEmailHttpEntity(email));
  } else {
    request.bodyForm(convertFrom(email.getParameters()).build(), UTF_8);
  }
  return request.execute().returnContent().asString(UTF_8);
}

相关文章