use of org.apache.http.util.CharArrayBuffer in project platform_external_apache-http by android.
the class BasicHeaderValueParser method parseElements.
// public default constructor
/**
* Parses elements with the given parser.
*
* @param value the header value to parse
* @param parser the parser to use, or <code>null</code> for default
*
* @return array holding the header elements, never <code>null</code>
*/
public static final HeaderElement[] parseElements(final String value, HeaderValueParser parser) throws ParseException {
if (value == null) {
throw new IllegalArgumentException("Value to parse may not be null");
}
if (parser == null)
parser = BasicHeaderValueParser.DEFAULT;
CharArrayBuffer buffer = new CharArrayBuffer(value.length());
buffer.append(value);
ParserCursor cursor = new ParserCursor(0, value.length());
return parser.parseElements(buffer, cursor);
}
use of org.apache.http.util.CharArrayBuffer in project platform_external_apache-http by android.
the class BasicHeaderValueParser method parseParameters.
/**
* Parses parameters with the given parser.
*
* @param value the parameter list to parse
* @param parser the parser to use, or <code>null</code> for default
*
* @return array holding the parameters, never <code>null</code>
*/
public static final NameValuePair[] parseParameters(final String value, HeaderValueParser parser) throws ParseException {
if (value == null) {
throw new IllegalArgumentException("Value to parse may not be null");
}
if (parser == null)
parser = BasicHeaderValueParser.DEFAULT;
CharArrayBuffer buffer = new CharArrayBuffer(value.length());
buffer.append(value);
ParserCursor cursor = new ParserCursor(0, value.length());
return parser.parseParameters(buffer, cursor);
}
use of org.apache.http.util.CharArrayBuffer in project platform_external_apache-http by android.
the class BasicLineFormatter method formatStatusLine.
// non-javadoc, see interface LineFormatter
public CharArrayBuffer formatStatusLine(final CharArrayBuffer buffer, final StatusLine statline) {
if (statline == null) {
throw new IllegalArgumentException("Status line may not be null");
}
CharArrayBuffer result = initBuffer(buffer);
doFormatStatusLine(result, statline);
return result;
}
use of org.apache.http.util.CharArrayBuffer in project platform_external_apache-http by android.
the class HttpRequestWriter method writeHeadLine.
protected void writeHeadLine(final HttpMessage message) throws IOException {
final CharArrayBuffer buffer = lineFormatter.formatRequestLine(this.lineBuf, ((HttpRequest) message).getRequestLine());
this.sessionBuffer.writeLine(buffer);
}
use of org.apache.http.util.CharArrayBuffer in project platform_external_apache-http by android.
the class BrowserCompatSpec method formatCookies.
public List<Header> formatCookies(final List<Cookie> cookies) {
if (cookies == null) {
throw new IllegalArgumentException("List of cookies may not be null");
}
if (cookies.isEmpty()) {
throw new IllegalArgumentException("List of cookies may not be empty");
}
CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size());
buffer.append(SM.COOKIE);
buffer.append(": ");
for (int i = 0; i < cookies.size(); i++) {
Cookie cookie = cookies.get(i);
if (i > 0) {
buffer.append("; ");
}
buffer.append(cookie.getName());
buffer.append("=");
String s = cookie.getValue();
if (s != null) {
buffer.append(s);
}
}
List<Header> headers = new ArrayList<Header>(1);
headers.add(new BufferedHeader(buffer));
return headers;
}
Aggregations