/** * This is used to determine whether the part body has been read * from the cursor successfully. In order to determine if all of * the bytes have been read successfully this will check to see * of the terminal token had been consumed. * * @return true if the part body and terminal have been read */ public boolean isFinished() { if(boundary.isEnd()) { return true; } return consumer.isFinished(); }
/** * This is used to acquire the body for this HTTP entity. This * will return a body which can be used to read the content of * the message, also if the request is multipart upload then all * of the parts are provided as <code>Part</code> objects. Each * part can then be read as an individual message. * * @return the body provided by the HTTP request message */ public Body getBody() { return entity.getBody(); }
/** * This is used to acquire the body that has been consumed. This * will return a body which can be used to read the content of * the message, also if the request is multipart upload then all * of the parts are provided as <code>Attachment</code> objects. * Each part can then be read as an individual message. * * @return the body that has been consumed by this instance */ public Body getBody() { return new BufferBody(buffer); }
/** * This is used to acquire the content type for this part. This * is typically the type of content for a file part, as provided * by a MIME type from the HTTP "Content-Type" header. * * @return this returns the content type for the part object */ public ContentType getContentType() { return segment.getContentType(); }
/** * This is used to acquire the part for this HTTP entity. This * will return a part which can be used to read the content of * the message, the part created contains the contents of the * body and the headers associated with it. * * @return the part provided by the HTTP request message */ public Part getPart() { return new BufferPart(segment, buffer); }
/** * This is used to create a string from the header bytes. This * converts the header bytes to a string using a compatible * encoding. This may produce different results depending on * the time it is invoked, as the header consumes more data. * * @return this returns an encoded version of the header */ public String toString() { return toString("UTF-8"); }
/** * This can be used to get the major number from a HTTP version. * The major version corresponds to the major type that is the 1 * of a HTTP/1.0 version string. * * @return the major version number for the request message */ public int getMajor() { return header.getMajor(); }
/** * This is a convenience method that can be used to determine * the length of the message body. This will determine if there * is a <code>Content-Length</code> header, if it does then the * length can be determined, if not then this returns -1. * * @return the content length, or -1 if it cannot be determined */ public long getContentLength() { return header.getContentLength(); }
/** * This method is used to get all <code>Part</code> objects that * are associated with the request. Each attachment contains the * body and headers associated with it. If the request is not a * multipart POST request then this will return an empty list. * * @return the list of parts associated with this request */ public List<Part> getParts() { return body.getParts(); } }
/** * This is used to determine whether the terminal token read is * the final terminal token. The final terminal token is a * normal terminal token, however it ends with two hyphens and * a carriage return line feed, this ends the part list. * * @return true if this was the last part within the list */ public boolean isEnd() { return boundary.isEnd(); } }
/** * This is used to acquire the address from the request line. * An address is the full URI including the scheme, domain, port * and the query parts. This allows various parameters to be * acquired without having to parse the raw request target URI. * * @return this returns the address of the request line */ public Address getAddress() { return header.getAddress(); }
/** * This is used to acquire the path as extracted from the HTTP * request URI. The <code>Path</code> object that is provided by * this method is immutable, it represents the normalized path * only part from the request uniform resource identifier. * * @return this returns the normalized path for the request */ public Path getPath() { return header.getPath(); }
/** * This method is used to get a <code>List</code> of the names * for the headers. This will provide the original names for the * HTTP headers for the message. Modifications to the provided * list will not affect the header, the list is a simple copy. * * @return this returns a list of the names within the header */ public List<String> getNames() { return header.getNames(); }
/** * This is a convenience method that can be used to determine the * content type of the message body. This will determine whether * there is a <code>Content-Type</code> header, if there is then * this will parse that header and represent it as a typed object * which will expose the various parts of the HTTP header. * * @return this returns the content type value if it exists */ public ContentType getContentType() { return header.getContentType(); }
/** * This method returns a <code>CharSequence</code> holding the header * consumed for the request. A character sequence is returned as it * can provide a much more efficient means of representing the header * data by just wrapping the consumed byte array. * * @return this returns the characters consumed for the header */ public CharSequence getHeader() { return header.getHeader(); }
/** * Pushes the provided data on to the cursor. Data pushed on to * the cursor will be the next data read from the cursor. This * complements the <code>reset</code> method which will reset * the cursors position on a stream. Allowing data to be pushed * on to the cursor allows more flexibility. * * @param data this is the data to be pushed on to the cursor */ public void push(byte[] data) throws IOException { push(data, 0, data.length); }
/** * Pushes the provided data on to the cursor. Data pushed on to * the cursor will be the next data read from the cursor. This * complements the <code>reset</code> method which will reset * the cursors position on a stream. Allowing data to be pushed * on to the cursor allows more flexibility. * * @param data this is the data to be pushed on to the cursor */ public void push(byte[] data) throws IOException { push(data, 0, data.length); }
/** * This is used to acquire the body for this HTTP entity. This * will return a body which can be used to read the content of * the message, also if the request is multipart upload then all * of the parts are provided as <code>Part</code> objects. Each * part can then be read as an individual message. * * @return the body provided by the HTTP request message */ public Body getBody() { return entity.getBody(); }
/** * Constructor for the <code>BufferPart</code> object. This is * used to create a part from a multipart body. Each part will * contain the headers associated with it as well as the body. * * @param segment this holds the headers for the part * @param buffer this represents the body for the part */ public BufferPart(Segment segment, Buffer buffer) { this.body = new BufferBody(buffer); this.segment = segment; }
/** * This is used to acquire the body for this HTTP entity. This * will return a body which can be used to read the content of * the message, also if the request is multipart upload then all * of the parts are provided as <code>Part</code> objects. Each * part can then be read as an individual message. * * @return the body provided by the HTTP request message */ public Body getBody() { return entity.getBody(); }