Search in sources :

Example 6 with IrregularUrlException

use of com.benmu.framework.http.okhttp.exception.IrregularUrlException in project WeexErosFramework by bmfe.

the class AxiosManager method post.

public void post(String mUrl, String data, HashMap<String, String> header, StringCallback stringCallback, Object tag, long timeout) {
    mUrl = safeUrl(mUrl);
    if (mUrl == null) {
        if (stringCallback != null) {
            stringCallback.onError(null, new IrregularUrlException("url不合法"), 0);
        }
        return;
    }
    setTimeout(timeout);
    String contentType = null;
    if (header != null) {
        contentType = header.get("Content-Type");
    }
    if (TextUtils.isEmpty(contentType)) {
        contentType = DEFAULT_MEDIATYPE;
    }
    OkHttpUtils.postString().url(mUrl).content(data).mediaType(MediaType.parse(contentType)).headers(header).tag(tag).build().execute(stringCallback);
}
Also used : IrregularUrlException(com.benmu.framework.http.okhttp.exception.IrregularUrlException)

Example 7 with IrregularUrlException

use of com.benmu.framework.http.okhttp.exception.IrregularUrlException in project WeexErosFramework by bmfe.

the class AxiosManager method put.

public void put(String url, String content, HashMap<String, String> header, StringCallback callBack, Object tag, long timeout) {
    url = safeUrl(url);
    if (url == null) {
        if (callBack != null) {
            callBack.onError(null, new IrregularUrlException("url不合法"), 0);
        }
        return;
    }
    if (header == null) {
        header = new HashMap<>();
    }
    setTimeout(timeout);
    OtherRequestBuilder builder = OkHttpUtils.put().url(url).tag(tag).headers(header);
    if (content != null) {
        builder.requestBody(createRequestBodyByMediaType(header, content));
    }
    builder.build().execute(callBack);
}
Also used : OtherRequestBuilder(com.benmu.framework.http.okhttp.builder.OtherRequestBuilder) IrregularUrlException(com.benmu.framework.http.okhttp.exception.IrregularUrlException)

Aggregations

IrregularUrlException (com.benmu.framework.http.okhttp.exception.IrregularUrlException)7 OtherRequestBuilder (com.benmu.framework.http.okhttp.builder.OtherRequestBuilder)3 GetBuilder (com.benmu.framework.http.okhttp.builder.GetBuilder)1 CancelException (com.benmu.framework.http.okhttp.exception.CancelException)1 HttpException (com.benmu.framework.http.okhttp.exception.HttpException)1 AxiosResultBean (com.benmu.framework.model.AxiosResultBean)1