Search in sources :

Example 1 with HttpMethod

use of org.httpkit.HttpMethod in project http-kit by http-kit.

the class HttpDecoder method createRequest.

private void createRequest(String sb) throws ProtocolException {
    int aStart;
    int aEnd;
    int bStart;
    int bEnd;
    int cStart;
    int cEnd;
    aStart = findNonWhitespace(sb, 0);
    aEnd = findWhitespace(sb, aStart);
    bStart = findNonWhitespace(sb, aEnd);
    bEnd = findWhitespace(sb, bStart);
    cStart = findNonWhitespace(sb, bEnd);
    cEnd = findEndOfString(sb, cStart);
    if (cStart < cEnd) {
        try {
            HttpMethod method = HttpMethod.valueOf(sb.substring(aStart, aEnd).toUpperCase());
            HttpVersion version = HTTP_1_1;
            if ("HTTP/1.0".equals(sb.substring(cStart, cEnd))) {
                version = HTTP_1_0;
            }
            request = new HttpRequest(method, sb.substring(bStart, bEnd), version);
        } catch (Exception e) {
            throw new ProtocolException("method not understand");
        }
    } else {
        throw new ProtocolException("not http?");
    }
}
Also used : ProtocolException(org.httpkit.ProtocolException) HttpVersion(org.httpkit.HttpVersion) HttpMethod(org.httpkit.HttpMethod) LineTooLargeException(org.httpkit.LineTooLargeException) ProtocolException(org.httpkit.ProtocolException) UnknownHostException(java.net.UnknownHostException) RequestTooLargeException(org.httpkit.RequestTooLargeException)

Aggregations

UnknownHostException (java.net.UnknownHostException)1 HttpMethod (org.httpkit.HttpMethod)1 HttpVersion (org.httpkit.HttpVersion)1 LineTooLargeException (org.httpkit.LineTooLargeException)1 ProtocolException (org.httpkit.ProtocolException)1 RequestTooLargeException (org.httpkit.RequestTooLargeException)1