Example usage for org.apache.http.protocol HTTP LF

List of usage examples for org.apache.http.protocol HTTP LF

Introduction

In this page you can find the example usage for org.apache.http.protocol HTTP LF.

Prototype

int LF

To view the source code for org.apache.http.protocol HTTP LF.

Click Source Link

Usage

From source file:com.subgraph.vega.ui.httpeditor.parser.ParserBase.java

/**
 * Get the next line of characters from a CharArrayBuffer into another CharArrayBuffer. Treats LF and CRLF as valid
 * line delimiters. Treats the entire buffer as a line if no line delimiters are found.
 * /*from  ww w .  jav  a 2  s . c om*/
 * @param src Source buffer to read line from.
 * @param srcCursor Parser cursor for src. Adjusted to discard line delimiters.
 * @param dst Destination buffer for characters from line. 
 * @return Number of characters in line minus line delimiters, or < 0 if none found.
 */
protected int readLine(final CharArrayBuffer src, final ParserCursor srcCursor, final CharArrayBuffer dst) {
    if (srcCursor.atEnd()) {
        return -1;
    }

    int idxPos = srcCursor.getPos();
    int idxLf = src.indexOf(HTTP.LF, idxPos, srcCursor.getUpperBound());
    int idxEnd;

    if (idxLf > 0) {
        if (src.charAt(idxLf - 1) == HTTP.CR) {
            idxEnd = idxLf - 1;
        } else {
            idxEnd = idxLf;
        }
    } else {
        idxEnd = srcCursor.getUpperBound();
        idxLf = idxEnd - 1;
    }

    dst.append(src, idxPos, idxEnd - idxPos);
    srcCursor.updatePos(idxLf + 1);
    return idxEnd - idxPos;
}

From source file:com.subgraph.vega.ui.httpeditor.parser.ParserBase.java

/**
 * Get the next header line of characters from a CharArrayBuffer into another CharArrayBuffer. Treats LF and CRLF as
 * valid line delimiters. Treats the entire buffer as a line if no line delimiters are found. Supports folded header
 * field values as per the HTTP/1.1 specification.
 *    /*from   ww  w  .j  a  v a2s .  co m*/
 * @param src Source buffer to read line from.
 * @param srcCursor Parser cursor for src. Adjusted to discard line delimiters.
 * @param dst Destination buffer for characters from line. 
 * @return Number of characters in line minus line delimiters, or < 0 if none found.
 */
protected int readLineHeader(final CharArrayBuffer src, final ParserCursor srcCursor,
        final CharArrayBuffer dst) {
    if (srcCursor.atEnd()) {
        return -1;
    }

    int idxPos = srcCursor.getPos();
    int chCnt = 0;
    int idxLf, idxEnd;

    do {
        idxLf = src.indexOf(HTTP.LF, idxPos, srcCursor.getUpperBound());

        if (idxLf > 0) {
            if (src.charAt(idxLf - 1) == HTTP.CR) {
                idxEnd = idxLf - 1;
            } else {
                idxEnd = idxLf;
            }
        } else {
            idxEnd = srcCursor.getUpperBound();
            idxLf = idxEnd - 1;
        }

        if (chCnt != 0) {
            while (idxPos < idxEnd && (src.charAt(idxPos) == HTTP.HT || src.charAt(idxPos) == HTTP.SP)) {
                idxPos++;
            }
            if (idxPos != idxEnd) {
                dst.append(' ');
            }
        }

        dst.append(src, idxPos, idxEnd - idxPos);
        chCnt += idxEnd - idxPos;
        idxPos = idxLf + 1;
        srcCursor.updatePos(idxPos);
    } while (idxPos < srcCursor.getUpperBound()
            && (src.charAt(idxPos) == HTTP.HT || src.charAt(idxPos) == HTTP.SP));

    return chCnt;
}

From source file:org.vietspider.net.apache.AbstractSessionInputBuffer.java

private int locateLF() {
    for (int i = this.bufferpos; i < this.bufferlen; i++) {
        if (this.buffer[i] == HTTP.LF)
            return i;
    }//from www  .  ja  va  2  s. com
    return -1;
}

From source file:org.deviceconnect.message.http.impl.factory.AbstractHttpMessageFactory.java

/**
 * HTTP???dConnect???.//w  ww  .  j a va  2s.c  om
 * @param dmessage dConnect
 * @param message HTTP
 */
protected void parseHttpBody(final DConnectMessage dmessage, final M message) {
    mLogger.entering(getClass().getName(), "newDConnectMessage", new Object[] { dmessage, message });

    HttpEntity entity = getHttpEntity(message);
    if (entity != null) {

        MimeStreamParser parser = new MimeStreamParser(new MimeEntityConfig());
        MultipartContentHandler handler = new MultipartContentHandler(dmessage);
        parser.setContentHandler(handler);

        StringBuilder headerBuffer = new StringBuilder();

        for (Header header : message.getAllHeaders()) {
            headerBuffer.append(header.getName());
            headerBuffer.append(": ");
            headerBuffer.append(header.getValue());
            headerBuffer.append(Character.toChars(HTTP.CR));
            headerBuffer.append(Character.toChars(HTTP.LF));
            mLogger.fine("header: " + header.getName() + ":" + header.getValue());
        }
        headerBuffer.append(Character.toChars(HTTP.CR));
        headerBuffer.append(Character.toChars(HTTP.LF));

        try {
            parser.parse(new SequenceInputStream(
                    new ByteArrayInputStream(headerBuffer.toString().getBytes("US-ASCII")),
                    entity.getContent()));
        } catch (IllegalStateException e) {
            mLogger.log(Level.FINE, e.toString(), e);
            mLogger.warning(e.toString());
        } catch (MimeException e) {
            mLogger.log(Level.FINE, e.toString(), e);
            mLogger.warning(e.toString());
        } catch (IOException e) {
            mLogger.log(Level.FINE, e.toString(), e);
            mLogger.warning(e.toString());
        }
    }

    mLogger.exiting(getClass().getName(), "newDConnectMessage");
}

From source file:org.vietspider.net.apache.AbstractSessionInputBuffer.java

private int lineFromLineBuffer(final CharArrayBuffer charbuffer) throws IOException {
    // discard LF if found
    int l = this.linebuffer.length();
    if (l > 0) {
        if (this.linebuffer.byteAt(l - 1) == HTTP.LF) {
            l--;/*from w  w w.j ava2  s .c  o  m*/
            this.linebuffer.setLength(l);
        }
        // discard CR if found
        if (l > 0) {
            if (this.linebuffer.byteAt(l - 1) == HTTP.CR) {
                l--;
                this.linebuffer.setLength(l);
            }
        }
    }
    l = this.linebuffer.length();
    if (this.ascii) {
        charbuffer.append(this.linebuffer, 0, l);
    } else {
        String s = new String(this.linebuffer.buffer(), 0, l, this.charset);
        charbuffer.append(s);
    }
    return l;
}

From source file:com.google.android.gms.common.C0270e.java

private static Dialog m3391b(int i, Activity activity, Fragment fragment, int i2,
        OnCancelListener onCancelListener) {
    Builder builder;//  w w  w. j a v  a  2s  . co  m
    Intent a;
    OnClickListener c0420i;
    CharSequence c;
    if (C0516u.m4166a((Context) activity) && i == 2) {
        i = 42;
    }
    if (C0519x.m4174c()) {
        TypedValue typedValue = new TypedValue();
        activity.getTheme().resolveAttribute(16843529, typedValue, true);
        if ("Theme.Dialog.Alert".equals(activity.getResources().getResourceEntryName(typedValue.resourceId))) {
            builder = new Builder(activity, 5);
            if (builder == null) {
                builder = new Builder(activity);
            }
            builder.setMessage(C0270e.m3392b(activity, i));
            if (onCancelListener != null) {
                builder.setOnCancelListener(onCancelListener);
            }
            a = C0270e.m3382a(i);
            c0420i = fragment != null ? new C0420i(activity, a, i2) : new C0420i(fragment, a, i2);
            c = C0270e.m3397c(activity, i);
            if (c != null) {
                builder.setPositiveButton(c, c0420i);
            }
            switch (i) {
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoPanelHeight /*0*/:
                return null;
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoShadowHeight /*1*/:
                return builder.setTitle(R.common_google_play_services_install_title).create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoParalaxOffset /*2*/:
                return builder.setTitle(R.common_google_play_services_update_title).create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoFadeColor /*3*/:
                return builder.setTitle(R.common_google_play_services_enable_title).create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoFlingVelocity /*4*/:
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoOverlay /*6*/:
                return builder.create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoDragView /*5*/:
                Log.e("GooglePlayServicesUtil",
                        "An invalid account was specified when connecting. Please provide a valid account.");
                return builder.setTitle(R.common_google_play_services_invalid_account_title).create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoClipPanel /*7*/:
                Log.e("GooglePlayServicesUtil", "Network error occurred. Please retry request later.");
                return builder.setTitle(R.common_google_play_services_network_error_title).create();
            case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoAnchorPoint /*8*/:
                Log.e("GooglePlayServicesUtil",
                        "Internal error occurred. Please see logs for detailed information");
                return builder.create();
            case HTTP.HT /*9*/:
                Log.e("GooglePlayServicesUtil", "Google Play services is invalid. Cannot recover.");
                return builder.setTitle(R.common_google_play_services_unsupported_title).create();
            case HTTP.LF /*10*/:
                Log.e("GooglePlayServicesUtil",
                        "Developer error occurred. Please see logs for detailed information");
                return builder.create();
            case com.olacabs.customer.R.R.MapM4bAttrs_m4b_uiZoomControls /*11*/:
                Log.e("GooglePlayServicesUtil", "The application is not licensed to the user.");
                return builder.create();
            case Constants.DEFAULT_MAP_ZOOM_LEVEL /*16*/:
                Log.e("GooglePlayServicesUtil",
                        "One of the API components you attempted to connect to is not available.");
                return builder.create();
            case LangUtils.HASH_SEED /*17*/:
                Log.e("GooglePlayServicesUtil", "The specified account could not be signed in.");
                return builder.setTitle(R.common_google_play_services_sign_in_failed_title).create();
            case 42:
                return builder.setTitle(R.common_android_wear_update_title).create();
            default:
                Log.e("GooglePlayServicesUtil", "Unexpected error code " + i);
                return builder.create();
            }
        }
    }
    builder = null;
    if (builder == null) {
        builder = new Builder(activity);
    }
    builder.setMessage(C0270e.m3392b(activity, i));
    if (onCancelListener != null) {
        builder.setOnCancelListener(onCancelListener);
    }
    a = C0270e.m3382a(i);
    if (fragment != null) {
    }
    c = C0270e.m3397c(activity, i);
    if (c != null) {
        builder.setPositiveButton(c, c0420i);
    }
    switch (i) {
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoPanelHeight /*0*/:
        return null;
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoShadowHeight /*1*/:
        return builder.setTitle(R.common_google_play_services_install_title).create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoParalaxOffset /*2*/:
        return builder.setTitle(R.common_google_play_services_update_title).create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoFadeColor /*3*/:
        return builder.setTitle(R.common_google_play_services_enable_title).create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoFlingVelocity /*4*/:
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoOverlay /*6*/:
        return builder.create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoDragView /*5*/:
        Log.e("GooglePlayServicesUtil",
                "An invalid account was specified when connecting. Please provide a valid account.");
        return builder.setTitle(R.common_google_play_services_invalid_account_title).create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoClipPanel /*7*/:
        Log.e("GooglePlayServicesUtil", "Network error occurred. Please retry request later.");
        return builder.setTitle(R.common_google_play_services_network_error_title).create();
    case com.sothree.slidinguppanel.p086a.R.R.SlidingUpPanelLayout_umanoAnchorPoint /*8*/:
        Log.e("GooglePlayServicesUtil", "Internal error occurred. Please see logs for detailed information");
        return builder.create();
    case HTTP.HT /*9*/:
        Log.e("GooglePlayServicesUtil", "Google Play services is invalid. Cannot recover.");
        return builder.setTitle(R.common_google_play_services_unsupported_title).create();
    case HTTP.LF /*10*/:
        Log.e("GooglePlayServicesUtil", "Developer error occurred. Please see logs for detailed information");
        return builder.create();
    case com.olacabs.customer.R.R.MapM4bAttrs_m4b_uiZoomControls /*11*/:
        Log.e("GooglePlayServicesUtil", "The application is not licensed to the user.");
        return builder.create();
    case Constants.DEFAULT_MAP_ZOOM_LEVEL /*16*/:
        Log.e("GooglePlayServicesUtil",
                "One of the API components you attempted to connect to is not available.");
        return builder.create();
    case LangUtils.HASH_SEED /*17*/:
        Log.e("GooglePlayServicesUtil", "The specified account could not be signed in.");
        return builder.setTitle(R.common_google_play_services_sign_in_failed_title).create();
    case 42:
        return builder.setTitle(R.common_android_wear_update_title).create();
    default:
        Log.e("GooglePlayServicesUtil", "Unexpected error code " + i);
        return builder.create();
    }
}