001/** 002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com). 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package io.jboot.components.http; 017 018import io.jboot.app.config.annotation.ConfigModel; 019import io.jboot.utils.StrUtil; 020 021 022@ConfigModel(prefix = "jboot.http") 023public class JbootHttpConfig { 024 public static final String TYPE_DEFAULT = "default"; 025 public static final String TYPE_HTTPCLIENT = "httpclient"; 026 public static final String TYPE_OKHTTP = "okhttp"; 027 028 public String type = TYPE_DEFAULT; 029 030 private String certPath; 031 private String certPass; 032 033 private int readTimeOut = JbootHttpRequest.READ_TIME_OUT; 034 private int connectTimeOut = JbootHttpRequest.CONNECT_TIME_OUT; 035 private String contentType = JbootHttpRequest.CONTENT_TYPE_URL_ENCODED; 036 037 private String proxyHost; 038 private Integer proxyPort; 039 private String proxyUser; 040 private String proxyPassword; 041 042 043 public String getType() { 044 return type; 045 } 046 047 public void setType(String type) { 048 this.type = type; 049 } 050 051 public String getCertPath() { 052 return certPath; 053 } 054 055 public void setCertPath(String certPath) { 056 this.certPath = certPath; 057 } 058 059 public String getCertPass() { 060 return certPass; 061 } 062 063 public void setCertPass(String certPass) { 064 this.certPass = certPass; 065 } 066 067 public int getReadTimeOut() { 068 return readTimeOut; 069 } 070 071 public void setReadTimeOut(int readTimeOut) { 072 this.readTimeOut = readTimeOut; 073 } 074 075 public int getConnectTimeOut() { 076 return connectTimeOut; 077 } 078 079 public void setConnectTimeOut(int connectTimeOut) { 080 this.connectTimeOut = connectTimeOut; 081 } 082 083 public String getContentType() { 084 return contentType; 085 } 086 087 public void setContentType(String contentType) { 088 this.contentType = contentType; 089 } 090 091 public String getProxyHost() { 092 return proxyHost; 093 } 094 095 public void setProxyHost(String proxyHost) { 096 this.proxyHost = proxyHost; 097 } 098 099 public Integer getProxyPort() { 100 return proxyPort; 101 } 102 103 public void setProxyPort(Integer proxyPort) { 104 this.proxyPort = proxyPort; 105 } 106 107 public String getProxyUser() { 108 return proxyUser; 109 } 110 111 public void setProxyUser(String proxyUser) { 112 this.proxyUser = proxyUser; 113 } 114 115 public String getProxyPassword() { 116 return proxyPassword; 117 } 118 119 public void setProxyPassword(String proxyPassword) { 120 this.proxyPassword = proxyPassword; 121 } 122 123 private HttpProxyInfo httpProxyInfo; 124 125 public HttpProxyInfo getHttpProxyInfo() { 126 if (httpProxyInfo != null) { 127 return httpProxyInfo; 128 } 129 if (StrUtil.isNotBlank(proxyHost) && proxyPort != null && proxyPort > 0) { 130 httpProxyInfo = new HttpProxyInfo(proxyHost, proxyPort, proxyUser, proxyPassword); 131 } 132 return httpProxyInfo; 133 } 134 135 136}