Java Code Examples for com.lidroid.xutils.http.RequestParams#HeaderItem

The following examples show how to use com.lidroid.xutils.http.RequestParams#HeaderItem . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpRequest.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
public void setRequestParams(RequestParams param) {
    if (param != null) {
        if (uriCharset == null) {
            uriCharset = Charset.forName(param.getCharset());
        }
        List<RequestParams.HeaderItem> headerItems = param.getHeaders();
        if (headerItems != null) {
            for (RequestParams.HeaderItem headerItem : headerItems) {
                if (headerItem.overwrite) {
                    this.setHeader(headerItem.header);
                } else {
                    this.addHeader(headerItem.header);
                }
            }
        }
        this.addQueryStringParams(param.getQueryStringParams());
        this.setEntity(param.getEntity());
    }
}
 
Example 2
Source File: HttpRequest.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
public void setRequestParams(RequestParams param, RequestCallBackHandler callBackHandler) {
    if (param != null) {
        if (uriCharset == null) {
            uriCharset = Charset.forName(param.getCharset());
        }
        List<RequestParams.HeaderItem> headerItems = param.getHeaders();
        if (headerItems != null) {
            for (RequestParams.HeaderItem headerItem : headerItems) {
                if (headerItem.overwrite) {
                    this.setHeader(headerItem.header);
                } else {
                    this.addHeader(headerItem.header);
                }
            }
        }
        this.addQueryStringParams(param.getQueryStringParams());
        HttpEntity entity = param.getEntity();
        if (entity != null) {
            if (entity instanceof UploadEntity) {
                ((UploadEntity) entity).setCallBackHandler(callBackHandler);
            }
            this.setEntity(entity);
        }
    }
}