congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Part
Code IndexAdd Tabnine to your IDE (free)

How to use
Part
in
org.apache.commons.httpclient.methods.multipart

Best Java code snippets using org.apache.commons.httpclient.methods.multipart.Part (Showing top 20 results out of 360)

origin: commons-httpclient/commons-httpclient

/**
 * Adds a <tt>Content-Type</tt> request header.
 *
 * @param state current state of http requests
 * @param conn the connection to use for I/O
 *
 * @throws IOException if an I/O (transport) error occurs. Some transport exceptions
 *                     can be recovered from.
 * @throws HttpException  if a protocol exception occurs. Usually protocol exceptions 
 *                    cannot be recovered from.
 * 
 * @since 3.0
 */
protected void addContentTypeRequestHeader(HttpState state,
                       HttpConnection conn)
throws IOException, HttpException {
  LOG.trace("enter EntityEnclosingMethod.addContentTypeRequestHeader("
       + "HttpState, HttpConnection)");
  if (!parameters.isEmpty()) {
    StringBuffer buffer = new StringBuffer(MULTIPART_FORM_CONTENT_TYPE);
    if (Part.getBoundary() != null) {
      buffer.append("; boundary=");
      buffer.append(Part.getBoundary());
    }
    setRequestHeader("Content-Type", buffer.toString());
  }
}
origin: commons-httpclient/commons-httpclient

/**
 * Write the content type header to the specified output stream
 * @param out The output stream
 * @throws IOException If an IO problem occurs.
 */
 protected void sendContentTypeHeader(OutputStream out) throws IOException {
  LOG.trace("enter sendContentTypeHeader(OutputStream out)");
  String contentType = getContentType();
  if (contentType != null) {
    out.write(CRLF_BYTES);
    out.write(CONTENT_TYPE_BYTES);
    out.write(EncodingUtil.getAsciiBytes(contentType));
    String charSet = getCharSet();
    if (charSet != null) {
      out.write(CHARSET_BYTES);
      out.write(EncodingUtil.getAsciiBytes(charSet));
    }
  }
}
origin: commons-httpclient/commons-httpclient

/**
 * Return the total sum of all parts and that of the last boundary
 * 
 * @param parts The parts.
 * @return The total length
 * 
 * @throws IOException If an I/O error occurs while writing the parts.
 */
public static long getLengthOfParts(Part[] parts)
throws IOException {
  return getLengthOfParts(parts, DEFAULT_BOUNDARY_BYTES);
}

origin: commons-httpclient/commons-httpclient

/**
 * Return the full length of all the data.
 * If you override this method make sure to override 
 * #send(OutputStream) as well
 * 
 * @return long The length.
 * @throws IOException If an IO problem occurs
 */
public long length() throws IOException {
  LOG.trace("enter length()");
  if (lengthOfData() < 0) {
    return -1;
  }
  ByteArrayOutputStream overhead = new ByteArrayOutputStream();
  sendStart(overhead);
  sendDispositionHeader(overhead);
  sendContentTypeHeader(overhead);
  sendTransferEncodingHeader(overhead);
  sendEndOfHeader(overhead);
  sendEnd(overhead);
  return overhead.size() + lengthOfData();
}
origin: commons-httpclient/commons-httpclient

for (int i = 0; i < parts.length; i++) {
  parts[i].setPartBoundary(partBoundary);
  long l = parts[i].length();
  if (l < 0) {
    return -1;
origin: commons-httpclient/commons-httpclient

/**
 * Return a string representation of this object.
 * @return A string representation of this object.
 * @see java.lang.Object#toString()
 */    
public String toString() {
  return this.getName();
}
origin: commons-httpclient/commons-httpclient

/**
 * Returns <code>true</code> if all parts are repeatable, <code>false</code> otherwise.
 * @see org.apache.commons.httpclient.methods.RequestEntity#isRepeatable()
 */
public boolean isRepeatable() {
  for (int i = 0; i < parts.length; i++) {
    if (!parts[i].isRepeatable()) {
      return false;
    }
  }
  return true;
}
origin: commons-httpclient/commons-httpclient

/**
 * Write the start to the specified output stream
 * @param out The output stream
 * @throws IOException If an IO problem occurs.
 */
protected void sendStart(OutputStream out) throws IOException {
  LOG.trace("enter sendStart(OutputStream out)");
  out.write(EXTRA_BYTES);
  out.write(getPartBoundary());
  out.write(CRLF_BYTES);
}

origin: commons-httpclient/commons-httpclient

/**
 * Write the content transfer encoding header to the specified 
 * output stream
 * 
 * @param out The output stream
 * @throws IOException If an IO problem occurs.
 */
 protected void sendTransferEncodingHeader(OutputStream out) throws IOException {
  LOG.trace("enter sendTransferEncodingHeader(OutputStream out)");
  String transferEncoding = getTransferEncoding();
  if (transferEncoding != null) {
    out.write(CRLF_BYTES);
    out.write(CONTENT_TRANSFER_ENCODING_BYTES);
    out.write(EncodingUtil.getAsciiBytes(transferEncoding));
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

/**
 * Return the full length of all the data.
 * If you override this method make sure to override 
 * #send(OutputStream) as well
 * 
 * @return long The length.
 * @throws IOException If an IO problem occurs
 */
public long length() throws IOException {
  LOG.trace("enter length()");
  if (lengthOfData() < 0) {
    return -1;
  }
  ByteArrayOutputStream overhead = new ByteArrayOutputStream();
  sendStart(overhead);
  sendDispositionHeader(overhead);
  sendContentTypeHeader(overhead);
  sendTransferEncodingHeader(overhead);
  sendEndOfHeader(overhead);
  sendEnd(overhead);
  return overhead.size() + lengthOfData();
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

for (int i = 0; i < parts.length; i++) {
  parts[i].setPartBoundary(partBoundary);
  long l = parts[i].length();
  if (l < 0) {
    return -1;
origin: commons-httpclient/commons-httpclient

/**
 * Write the content disposition header to the specified output stream
 * 
 * @param out The output stream
 * @throws IOException If an IO problem occurs.
 */
protected void sendDispositionHeader(OutputStream out) throws IOException {
  LOG.trace("enter sendDispositionHeader(OutputStream out)");
  out.write(CONTENT_DISPOSITION_BYTES);
  out.write(QUOTE_BYTES);
  out.write(EncodingUtil.getAsciiBytes(getName()));
  out.write(QUOTE_BYTES);
}

origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

/**
 * Returns <code>true</code> if all parts are repeatable, <code>false</code> otherwise.
 * @see org.apache.commons.httpclient.methods.RequestEntity#isRepeatable()
 */
public boolean isRepeatable() {
  for (int i = 0; i < parts.length; i++) {
    if (!parts[i].isRepeatable()) {
      return false;
    }
  }
  return true;
}
origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

/**
 * Write the start to the specified output stream
 * @param out The output stream
 * @throws IOException If an IO problem occurs.
 */
protected void sendStart(OutputStream out) throws IOException {
  LOG.trace("enter sendStart(OutputStream out)");
  out.write(EXTRA_BYTES);
  out.write(getPartBoundary());
  out.write(CRLF_BYTES);
}

origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

/**
 * Write the content transfer encoding header to the specified 
 * output stream
 * 
 * @param out The output stream
 * @throws IOException If an IO problem occurs.
 */
 protected void sendTransferEncodingHeader(OutputStream out) throws IOException {
  LOG.trace("enter sendTransferEncodingHeader(OutputStream out)");
  String transferEncoding = getTransferEncoding();
  if (transferEncoding != null) {
    out.write(CRLF_BYTES);
    out.write(CONTENT_TRANSFER_ENCODING_BYTES);
    out.write(EncodingUtil.getAsciiBytes(transferEncoding));
  }
}
origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

/**
 * Return the full length of all the data.
 * If you override this method make sure to override 
 * #send(OutputStream) as well
 * 
 * @return long The length.
 * @throws IOException If an IO problem occurs
 */
public long length() throws IOException {
  LOG.trace("enter length()");
  if (lengthOfData() < 0) {
    return -1;
  }
  ByteArrayOutputStream overhead = new ByteArrayOutputStream();
  sendStart(overhead);
  sendDispositionHeader(overhead);
  sendContentTypeHeader(overhead);
  sendTransferEncodingHeader(overhead);
  sendEndOfHeader(overhead);
  sendEnd(overhead);
  return overhead.size() + lengthOfData();
}
origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

/**
 * Write the content type header to the specified output stream
 * @param out The output stream
 * @throws IOException If an IO problem occurs.
 */
 protected void sendContentTypeHeader(OutputStream out) throws IOException {
  LOG.trace("enter sendContentTypeHeader(OutputStream out)");
  String contentType = getContentType();
  if (contentType != null) {
    out.write(CRLF_BYTES);
    out.write(CONTENT_TYPE_BYTES);
    out.write(EncodingUtil.getAsciiBytes(contentType));
    String charSet = getCharSet();
    if (charSet != null) {
      out.write(CHARSET_BYTES);
      out.write(EncodingUtil.getAsciiBytes(charSet));
    }
  }
}
origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

for (int i = 0; i < parts.length; i++) {
  parts[i].setPartBoundary(partBoundary);
  long l = parts[i].length();
  if (l < 0) {
    return -1;
origin: commons-httpclient/commons-httpclient

/**
 * <p>Return the length of the request body.</p>
 *
 * <p>Once this method has been invoked, the request parameters cannot be
 * altered until the method is {@link #recycle recycled}.</p>
 * 
 * @return The request content length.
 */
protected long getRequestContentLength() throws IOException {
  LOG.trace("enter MultipartPostMethod.getRequestContentLength()");
  return Part.getLengthOfParts(getParts());
}
origin: org.apache.commons/httpclient

/**
 * Return a string representation of this object.
 * @return A string representation of this object.
 * @see java.lang.Object#toString()
 */    
public String toString() {
  return this.getName();
}
org.apache.commons.httpclient.methods.multipartPart

Javadoc

Abstract class for one Part of a multipart post object.

Most used methods

  • getBoundary
    Return the boundary string.
  • getCharSet
    Return the character encoding of this part.
  • getContentType
    Returns the content type of this part.
  • getLengthOfParts
    Gets the length of the multipart message including the given parts.
  • getName
    Return the name of this part.
  • getPartBoundary
    Gets the part boundary to be used.
  • getTransferEncoding
    Return the transfer encoding of this part.
  • isRepeatable
    Tests if this part can be sent more than once.
  • length
    Return the full length of all the data. If you override this method make sure to override #send(Outp
  • lengthOfData
    Return the length of the main content
  • send
    Write all the data to the output stream. If you override this method make sure to override #length()
  • sendContentTypeHeader
    Write the content type header to the specified output stream
  • send,
  • sendContentTypeHeader,
  • sendData,
  • sendDispositionHeader,
  • sendEnd,
  • sendEndOfHeader,
  • sendParts,
  • sendStart,
  • sendTransferEncodingHeader,
  • setPartBoundary

Popular in Java

  • Start an intent from android
  • onRequestPermissionsResult (Fragment)
  • getContentResolver (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • JButton (javax.swing)
  • JOptionPane (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now