Search in sources :

Example 1 with StringCallback

use of com.koushikdutta.async.LineEmitter.StringCallback in project AndroidAsync by koush.

the class MultipartFormDataBody method onBoundaryStart.

@Override
protected void onBoundaryStart() {
    final Headers headers = new Headers();
    liner = new LineEmitter();
    liner.setLineCallback(new StringCallback() {

        @Override
        public void onStringAvailable(String s) {
            if (!"\r".equals(s)) {
                headers.addLine(s);
            } else {
                handleLast();
                liner = null;
                setDataCallback(null);
                Part part = new Part(headers);
                if (mCallback != null)
                    mCallback.onPart(part);
                if (getDataCallback() == null) {
                    if (part.isFile()) {
                        setDataCallback(new NullDataCallback());
                        return;
                    }
                    lastName = part.getName();
                    last = new ByteBufferList();
                    setDataCallback(new DataCallback() {

                        @Override
                        public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
                            bb.get(last);
                        }
                    });
                }
            }
        }
    });
    setDataCallback(liner);
}
Also used : ByteBufferList(com.koushikdutta.async.ByteBufferList) LineEmitter(com.koushikdutta.async.LineEmitter) Headers(com.koushikdutta.async.http.Headers) DataEmitter(com.koushikdutta.async.DataEmitter) StringCallback(com.koushikdutta.async.LineEmitter.StringCallback) DataCallback(com.koushikdutta.async.callback.DataCallback)

Aggregations

ByteBufferList (com.koushikdutta.async.ByteBufferList)1 DataEmitter (com.koushikdutta.async.DataEmitter)1 LineEmitter (com.koushikdutta.async.LineEmitter)1 StringCallback (com.koushikdutta.async.LineEmitter.StringCallback)1 DataCallback (com.koushikdutta.async.callback.DataCallback)1 Headers (com.koushikdutta.async.http.Headers)1