发送http请求，支持http和https方式

@param serverUrl 请求地址
@param realData 需要发送的数据
@return
342869
public static String post(
      String serverUrl, String realData, int connectTimeout, int readTimeout, String charset)
      throws NoSuchAlgorithmException, KeyManagementException, IOException {
    if (serverUrl == null || "".equals(serverUrl.trim())) {
      throw new NullPointerException("请求地址为空!");
    }
    if (realData == null || "".equals(realData.trim())) {
      throw new NullPointerException("请求数据为空!");
    }
    URLConnection conn;
    // 分别调用http或https请求
    if (serverUrl.startsWith(HTTPS_PREFIX)) {
      SSLContext sslContext = SSLContext.getInstance("TLS");
      X509TrustManager[] xtmArray = new X509TrustManager[] {xtm};
      sslContext.init(null, xtmArray, new java.security.SecureRandom());
      HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
      HttpsURLConnection.setDefaultHostnameVerifier(hnv);
      HttpsURLConnection httpsUrlConn = (HttpsURLConnection) (new URL(serverUrl)).openConnection();
      httpsUrlConn.setRequestMethod("POST");
      conn = httpsUrlConn;
    } else {
      URL url = new URL(serverUrl);
      conn = url.openConnection();
    }
    conn.setConnectTimeout(connectTimeout * 1000);
    conn.setReadTimeout(readTimeout * 1000);
    conn.setRequestProperty("Content-Type", "application/json;charset=" + charset);

    conn.setDoOutput(true);
    conn.setDoInput(true);

    OutputStream out = conn.getOutputStream();
    try {
      out.write(realData.getBytes(charset));
      out.flush();
    } finally {
      out.close();
    }

    InputStream is = conn.getInputStream();
    // 返回收到的响应数据
    return getResponseStringData(is, charset);
  }
1087482
@Override
    InterfaceHttpData getData(HttpRequest request, HttpDataFactory factory) {
        MediaType mediaType = contentType;
        String contentType = mediaType.toString();
        String encoding = mediaType.isTextBased() ? null : "binary";
        Charset charset = mediaType.getCharset().orElse(null);
        FileUpload fileUpload = factory.createFileUpload(request, name, filename, contentType,
            encoding, charset, getLength());
        try {
            setContent(fileUpload);
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
        return fileUpload;
    }
645564
public static HttpMessage fromResponseData(final String responseData) {
        try (final BufferedReader reader = new BufferedReader(new StringReader(responseData))) {
            final HttpMessage response = new HttpMessage();

            final String[] statusLine = reader.readLine().split("\\s");
            if (statusLine.length > 0) {
                response.version(statusLine[0]);
            }

            if (statusLine.length > 1) {
                response.status(HttpStatus.valueOf(Integer.valueOf(statusLine[1])));
            }

            return parseHttpMessage(reader, response);
        } catch (final IOException e) {
            throw new CitrusRuntimeException("Failed to parse Http raw response data", e);
        }
    }
848248
private static void serializeReal(final Number real, final ContentHandler handler) throws SAXException {
    serializeElement("real", String.valueOf(real.doubleValue()), handler);
  }
184165
public InitializrServiceMetadata loadMetadata(String serviceUrl) throws IOException {
		CloseableHttpResponse httpResponse = executeInitializrMetadataRetrieval(
				serviceUrl);
		validateResponse(httpResponse, serviceUrl);
		return parseJsonMetadata(httpResponse.getEntity());
	}
734765
public function requestServerData($uri, $postData = [])
    {
        $result = Http::post($this->createServerUrl($uri), function ($http) use ($postData) {
            $this->applyHttpAttributes($http, $postData);
        });

        if ($result->code == 404) {
            throw new ApplicationException(Lang::get('system::lang.server.response_not_found'));
        }

        if ($result->code != 200) {
            throw new ApplicationException(
                strlen($result->body)
                ? $result->body
                : Lang::get('system::lang.server.response_empty')
            );
        }

        $resultData = false;

        try {
            $resultData = @json_decode($result->body, true);
        }
        catch (Exception $ex) {
            throw new ApplicationException(Lang::get('system::lang.server.response_invalid'));
        }

        if ($resultData === false || (is_string($resultData) && !strlen($resultData))) {
            throw new ApplicationException(Lang::get('system::lang.server.response_invalid'));
        }

        return $resultData;
    }
1131417
private Bitmap  checkForImageDataURL(String url)
   {
      if (!url.startsWith("data:"))
         return null;
      if (url.length() < 14)
         return null;

      int  comma = url.indexOf(',');
      if (comma == -1 || comma < 12)
         return null;
      if (!";base64".equals(url.substring(comma-7, comma)))
         return null;
      byte[]  imageData = Base64.decode(url.substring(comma+1), Base64.DEFAULT);
      return BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
   }
1079129
public TLSARecord getTLSARecord(URL url) {

        String recordValue;

        int port = url.getPort();
        if (port == -1) {
            port = url.getDefaultPort();
        }
        String tlsaRecordName = String.format("_%s._tcp.%s", port, DNSUtil.ensureDot(url.getHost()));
        try {
            recordValue = this.dnssecResolver.resolve(tlsaRecordName, Type.TLSA);
        } catch (DNSSECException e) {
            return null;
        }

        if (recordValue.equals("")) return null;

        // Process TLSA Record
        String[] tlsaValues = recordValue.split(" ");
        if (tlsaValues.length != 4) return null;
        try {
            return new TLSARecord(
                    new Name(tlsaRecordName),
                    DClass.IN,
                    0,
                    Integer.parseInt(tlsaValues[0]),
                    Integer.parseInt(tlsaValues[1]),
                    Integer.parseInt(tlsaValues[2]),
                    BaseEncoding.base16().decode(tlsaValues[3])
            );
        } catch (TextParseException e) {
            return null;
        }
    }
388290
public ApiResponse<ApiSuccessResponse> getWorkbinsContentWithHttpInfo(GetWorkbinsContentData getWorkbinsContentData) throws ApiException {
        com.squareup.okhttp.Call call = getWorkbinsContentValidateBeforeCall(getWorkbinsContentData, null, null);
        Type localVarReturnType = new TypeToken<ApiSuccessResponse>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
1371404
public <T> T getJsonData(Class<T> clazz, RemoteUrl remoteUrl, int retryTimes, int retrySleepSeconds)
            throws Exception {
        Exception ex = null;
        for (URL url : remoteUrl.getUrls()) {

            // 可重试的下载
            UnreliableInterface unreliableImpl = new RestfulGet<T>(clazz, url);

            try {

                T t = retryStrategy.retry(unreliableImpl, retryTimes, retrySleepSeconds);

                return t;

            } catch (Exception e) {
                ex = e;
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e1) {
                    LOGGER.info("pass");
                }
            }
        }

        throw new Exception("cannot get: " + remoteUrl, ex);
    }
1313299
public static DataSource createDataSource(String url) throws SQLException {
        assertNotNull(url);

        BasicDataSource ds = new BasicDataSource();
        ds.setUrl(url);

        return ds;
    }
768220
public static HttpConnection create(String urlStr, Proxy proxy) {
		return create(URLUtil.toUrlForHttp(urlStr), proxy);
	}
37170
public RFuture<String> post(String url, String data) {
    return req(url).setPayload(data).execute().map(GET_PAYLOAD);
  }
241606
static HttpData getSsoForm(String remoteEndpointUrl,
                               String paramName, String paramValue,
                               @Nullable String relayState) {
        requireNonNull(remoteEndpointUrl, "remoteEndpointUrl");
        requireNonNull(paramName, "paramName");
        requireNonNull(paramValue, "paramValue");

        final StringBuilder html = new StringBuilder();
        html.append(XHTML.get(0))
            .append(XHTML.get(1)).append(HTML_ESCAPER.escape(remoteEndpointUrl)).append(XHTML.get(2))
            .append(XHTML.get(3)).append(HTML_ESCAPER.escape(paramName))
            .append(XHTML.get(4)).append(HTML_ESCAPER.escape(paramValue)).append(XHTML.get(5));

        if (relayState != null) {
            html.append(XHTML.get(3)).append(RELAY_STATE)
                .append(XHTML.get(4)).append(HTML_ESCAPER.escape(relayState)).append(XHTML.get(5));
        }
        html.append(XHTML.get(6));

        return HttpData.ofUtf8(html.toString());
    }
154689
@SuppressWarnings("deprecation")
    @Override
    public String getRealPath(String arg0) {
        try {
            collaborator.preInvoke(componentMetaData);
            return request.getRealPath(arg0);
        } finally {
            collaborator.postInvoke();
        }
    }
862601
private String requestWebPage(URL url) throws FanartTvException {
        try {
            HttpGet httpGet = new HttpGet(url.toURI());
            httpGet.addHeader("accept", "application/json");
            final DigestedResponse response = DigestedResponseReader.requestContent(httpClient, httpGet, charset);

            if (response.getStatusCode() >= 500) {
                throw new FanartTvException(ApiExceptionType.HTTP_503_ERROR, response.getContent(), response.getStatusCode(), url);
            } else if (response.getStatusCode() >= 300) {
                throw new FanartTvException(ApiExceptionType.HTTP_404_ERROR, response.getContent(), response.getStatusCode(), url);
            }

            return response.getContent();
        } catch (URISyntaxException ex) {
            throw new FanartTvException(ApiExceptionType.CONNECTION_ERROR, "Invalid URL", url, ex);
        } catch (IOException ex) {
            throw new FanartTvException(ApiExceptionType.CONNECTION_ERROR, "Error retrieving URL", url, ex);
        }
    }
882771
public final HttpClient baseUrl(String baseUrl) {
		Objects.requireNonNull(baseUrl, "baseUrl");
		return tcpConfiguration(tcp -> tcp.bootstrap(b -> HttpClientConfiguration.baseUrl(b, baseUrl)));
	}