Java 类org.apache.http.entity.mime.MIME 实例源码

项目:cyberduck    文件:DelayedHttpMultipartEntity.java   
/**
 * @param status Length
 */
public DelayedHttpMultipartEntity(final String filename, final TransferStatus status, final String boundary) {
    this.status = status;
    final StringBuilder multipartHeader = new StringBuilder();
    multipartHeader.append(TWO_DASHES);
    multipartHeader.append(boundary);
    multipartHeader.append(CR_LF);
    multipartHeader.append(String.format("Content-Disposition: form-data; name=\"file\"; filename=\"%s\"", filename));
    multipartHeader.append(CR_LF);
    multipartHeader.append(String.format("%s: %s", HTTP.CONTENT_TYPE, StringUtils.isBlank(status.getMime()) ? MimeTypeService.DEFAULT_CONTENT_TYPE : status.getMime()));
    multipartHeader.append(CR_LF);
    multipartHeader.append(CR_LF);
    header = encode(MIME.DEFAULT_CHARSET, multipartHeader.toString()).buffer();
    final StringBuilder multipartFooter = new StringBuilder();
    multipartFooter.append(CR_LF);
    multipartFooter.append(TWO_DASHES);
    multipartFooter.append(boundary);
    multipartFooter.append(TWO_DASHES);
    multipartFooter.append(CR_LF);
    footer = encode(MIME.DEFAULT_CHARSET, multipartFooter.toString()).buffer();
}
项目:telegrambot-japi    文件:TestBotRequest.java   
@Test
public void testUpdateRequest() {

    UpdateRequest updateRequest = Mockito.mock(UpdateRequest.class);

    when(updateRequest.getCommand()).thenReturn("getUpdates");

    MultipartEntityBuilder requestEntity = MultipartEntityBuilder.create();
    // New MIME type, data need to be UTF-8 encrypted
    ContentType contentType = ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), MIME.UTF8_CHARSET);

    // Set timout, limit and offset
    requestEntity.addTextBody("timeout", "60", contentType);
    requestEntity.addTextBody("limit", "100", contentType);
    requestEntity.addTextBody("offset", "1337", contentType);

    when(updateRequest.getRequestEntity()).thenReturn(requestEntity);

    BotRequest request = new BotRequest(updateRequest);
    assertEquals("getUpdates", request.getCommand());
    assertEquals(requestEntity, request.getContent());
}
项目:GeoKnowGeneratorUI    文件:BatchAdminClient.java   
/**
 * Runs a job with the defined parameters.
 * 
 * @param jobName name of the job
 * @param jobParameters job parameters for the execution
 * @param springBatchServiceUri the URI of Spring Batch Admin
 * @return JobExecution
 * @throws ServiceNotAvailableException
 * @throws ServiceInternalServerError
 * @throws Exception
 */
public static JobExecution runJob(String jobName, String jobParameters,
    String springBatchServiceUri) throws ResourceNotFoundException, UnknownException,
    IOException, ServiceNotAvailableException, ServiceInternalServerError {
  HttpPost postJob = new HttpPost(springBatchServiceUri + "/jobs/" + jobName + ".json");
  postJob.addHeader(MIME.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED);

  log.debug("execute " + jobName + " with parameters: " + jobParameters);
  ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
  postParameters.add(new BasicNameValuePair("jobParameters", jobParameters));
  postJob.setEntity(new UrlEncodedFormEntity(postParameters));

  String jsonString = apiRequest(postJob);
  Gson gson = new Gson();
  JobExecutionWrapper execution = gson.fromJson(jsonString, JobExecutionWrapper.class);
  return execution.getJobExecution();
}
项目:infoarchive-sip-sdk    文件:ContentResultFactory.java   
@Override
protected ContentResult doCreate(Response response, InputStream resultStream, Runnable closeResult) {
  final int length = response.getHeaderValue("Content-Length", -1);
  final String format = response.getHeaderValue(MIME.CONTENT_TYPE, MediaTypes.BINARY);
  final String name = extractFileNameFrom(response.getHeaderValue(MIME.CONTENT_DISPOSITION, ""));
  return new DefaultContentResult(name, length, format, resultStream, closeResult);
}
项目:aet    文件:JsonResponseHandler.java   
@Override
public T handleResponse(HttpResponse httpResponse) throws IOException {
  StatusLine statusLine = httpResponse.getStatusLine();
  if (statusLine.getStatusCode() == 200) {
    String result = EntityUtils.toString(httpResponse.getEntity(), MIME.UTF8_CHARSET);
    Gson gson = new Gson();
    return gson.fromJson(result, resultClass);
  } else {
    throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase());
  }
}
项目:telegrambot-japi    文件:UpdateRequest.java   
public UpdateRequest(Integer nextExpectedMsg) {
    this.offset = nextExpectedMsg;

    this.requestEntity = MultipartEntityBuilder.create();
    // New MIME type, data need to be UTF-8 encrypted
    ContentType contentType = ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), MIME.UTF8_CHARSET);

    // Set timout, limit and offset
    requestEntity.addTextBody(KEY_MSG_UPDATE_TIMEOUT, TIMEOUT.toString(), contentType);
    requestEntity.addTextBody(KEY_MSG_UPDATE_LIMIT, LIMIT.toString(), contentType);
    requestEntity.addTextBody(KEY_MSG_UPDATE_OFFSET, offset.toString(), contentType);

}
项目:telegrambot-japi    文件:BotRequest.java   
/**
 * Send a message to Telegram. This could be a text, image, audio, ...
 * message.
 * 
 * @param message
 */
public BotRequest(Message message) {
    this.command = message.getCommand();

    this.requestEntity = MultipartEntityBuilder.create();
    // New MIME type, data need to be UTF-8 encrypted
    ContentType contentType = ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), MIME.UTF8_CHARSET);

    // Set recipient, needed for every message
    requestEntity.addTextBody(KEY_RECIPIENT, message.getRecipient().toString(), contentType);

    // Add some more things, like a message text or an image
    switch (message.getMessageType()) {

    case TEXT_MESSAGE:
        requestEntity.addTextBody(message.getJsonKey(), (String) message.getMessage(), contentType);
        break;

    case IMAGE_MESSAGE:
    case DOCUMENT_MESSAGE:
    case AUDIO_MESSAGE:
    case VIDEO_MESSAGE:
        requestEntity.addBinaryBody(message.getJsonKey(), (File) message.getMessage());
        break;

    default:
        LOG.error("Message type is invalid, not supported or not yet implemented");
        break;
    }
}
项目:iaf    文件:HttpSender.java   
protected FormBodyPart createMultipartBodypart(String name, String message, String contentType) {
    FormBodyPartBuilder bodyPart = FormBodyPartBuilder.create()
        .setName(name)
        .setBody(new StringBody(message, ContentType.create(contentType, getCharSet())));

    if (StringUtils.isNotEmpty(getMtomContentTransferEncoding()))
        bodyPart.setField(MIME.CONTENT_TRANSFER_ENC, getMtomContentTransferEncoding());

    return bodyPart.build();
}
项目:boohee_v5.6    文件:FileBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:boohee_v5.6    文件:InputStreamBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:boohee_v5.6    文件:StringBody.java   
public String getTransferEncoding() {
    return MIME.ENC_8BIT;
}
项目:boohee_v5.6    文件:ByteArrayBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:OSCAR-ConCert    文件:ByteArrayBody.java   
public String getTransferEncoding() {
    return (MIME.ENC_BINARY);
}
项目:purecloud-iot    文件:FileBody.java   
@Override
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:purecloud-iot    文件:InputStreamBody.java   
@Override
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:purecloud-iot    文件:StringBody.java   
@Override
public String getTransferEncoding() {
    return MIME.ENC_8BIT;
}
项目:purecloud-iot    文件:ByteArrayBody.java   
@Override
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:tellervo    文件:XMLBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:tellervo    文件:UTF8StringBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:Lucee4    文件:ResourceBody.java   
@Override
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:Lucee    文件:ResourceBody.java   
@Override
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:ti.box    文件:FileBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:ti.box    文件:InputStreamBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:ti.box    文件:StringBody.java   
public String getTransferEncoding() {
    return MIME.ENC_8BIT;
}
项目:EmopAndroid    文件:FileBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:EmopAndroid    文件:InputStreamBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:EmopAndroid    文件:StringBody.java   
public String getTransferEncoding() {
    return MIME.ENC_8BIT;
}
项目:EmopAndroid    文件:ByteArrayBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:SoundcloudAPI    文件:Request.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:wildfly-core    文件:HttpGenericOperationUnitTestCase.java   
@Override
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:kaa    文件:ByteArrayBody.java   
@Override
public String getTransferEncoding() {
  return MIME.ENC_BINARY;
}
项目:MAKEYOURFACE    文件:FileBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:MAKEYOURFACE    文件:InputStreamBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:MAKEYOURFACE    文件:StringBody.java   
public String getTransferEncoding() {
    return MIME.ENC_8BIT;
}
项目:MAKEYOURFACE    文件:ByteArrayBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:paperchains    文件:Request.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:TensionCamApp    文件:FileBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:TensionCamApp    文件:InputStreamBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
项目:TensionCamApp    文件:StringBody.java   
public String getTransferEncoding() {
    return MIME.ENC_8BIT;
}
项目:TensionCamApp    文件:ByteArrayBody.java   
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}