Search in sources :

Example 1 with TaskInfoForm

use of lee.study.down.mvc.form.TaskInfoForm in project proxyee-down by monkeyWie.

the class DownContent method setUrl.

public static List<TaskInfoForm> setUrl(List<TaskInfo> taskInfoList) {
    List<TaskInfoForm> ret = new ArrayList<>();
    for (TaskInfo taskInfo : taskInfoList) {
        TaskInfoForm taskInfoForm = new TaskInfoForm();
        BeanUtils.copyProperties(taskInfo, taskInfoForm);
        HttpRequestInfo httpRequest = (HttpRequestInfo) ContentManager.DOWN.getDownInfo(taskInfo.getId()).getRequest();
        String uri = httpRequest.uri();
        String host = httpRequest.requestProto().getHost();
        String url = (uri.indexOf("/") == 0 ? host : "") + uri;
        if (url.indexOf("http://") != 0 && url.indexOf("https://") != 0) {
            url = (httpRequest.requestProto().getSsl() ? "https://" : "http://") + url;
        }
        taskInfoForm.setUrl(url);
        ret.add(taskInfoForm);
    }
    return ret;
}
Also used : TaskInfo(lee.study.down.model.TaskInfo) ArrayList(java.util.ArrayList) HttpRequestInfo(lee.study.down.model.HttpRequestInfo) TaskInfoForm(lee.study.down.mvc.form.TaskInfoForm)

Aggregations

ArrayList (java.util.ArrayList)1 HttpRequestInfo (lee.study.down.model.HttpRequestInfo)1 TaskInfo (lee.study.down.model.TaskInfo)1 TaskInfoForm (lee.study.down.mvc.form.TaskInfoForm)1