/*
(non-Javadoc)
@see java.net.URLConnection#getContentEncoding()
766532
@Override
   public String getContentEncoding()
   {
      try
      {
         if (!connected)
         {
            connect();
         }

         return nodeRepresentation.getContentEncoding();
      }
      catch (Exception e)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace("An exception occurred: " + e.getMessage());
         }
      }
      return null;
   }
890633
public void setContentEncoding(String contentEncoding) throws InvalidArgumentException {
    if (Strings.isNullOrEmpty(contentEncoding)) {
      throw new InvalidArgumentException("empty content encoding");
    }

    this.contentEncoding = contentEncoding;
  }
265052
@Override
    public Content getContent(String key, Object o1, Object o2) {
        return contents.getContent(key, o1, o2);
    }
315559
public String getContent() {
        if (content != null) {
            return context != null ? context.replaceDynamicContentInString(content) : content;
        } else if (StringUtils.hasText(getContentResourcePath()) && getContentType().startsWith("text")) {
            try {
                String fileContent = FileUtils.readToString(new PathMatchingResourcePatternResolver().getResource(getContentResourcePath()).getInputStream(), Charset.forName(charsetName));
                return context != null ? context.replaceDynamicContentInString(fileContent) : fileContent;
            } catch (IOException e) {
                throw new CitrusRuntimeException("Failed to read SOAP attachment file resource", e);
            }
        } else {
            try {
                byte[] binaryData = FileCopyUtils.copyToByteArray(getDataHandler().getInputStream());
                if (encodingType.equals(SoapAttachment.ENCODING_BASE64_BINARY)) {
                    return Base64.encodeBase64String(binaryData);
                } else if (encodingType.equals(SoapAttachment.ENCODING_HEX_BINARY)) {
                    return Hex.encodeHexString(binaryData).toUpperCase();
                } else {
                    throw new CitrusRuntimeException(String.format("Unsupported encoding type '%s' for SOAP attachment - choose one of %s or %s",
                            encodingType, SoapAttachment.ENCODING_BASE64_BINARY, SoapAttachment.ENCODING_HEX_BINARY));
                }
            } catch (IOException e) {
                throw new CitrusRuntimeException("Failed to read SOAP attachment data input stream", e);
            }
        }
    }
853234
public static String getContent(String stringUrl, Map<String, String> requestProperties) {
    try {
      URL url = new URL(stringUrl);
      URLConnection conn = url.openConnection();
      
      if (requestProperties != null) {
        for (Entry<String, String> entry : requestProperties.entrySet()) {
          conn.setRequestProperty(entry.getKey(), entry.getValue());
        }
      }
      
      InputStream is = conn.getInputStream();
      if ("gzip".equals(conn.getContentEncoding())) {
         is = new GZIPInputStream(is);
      }

      return MyStreamUtils.readContent(is);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return null;
  }
964427
public ContentKeyType getContentKeyType() {
        Integer contentKeyTypeInteger = getContent().getContentKeyType();
        ContentKeyType contentKeyType = null;
        if (contentKeyTypeInteger != null) {
            contentKeyType = ContentKeyType.fromCode(contentKeyTypeInteger);
        }
        return contentKeyType;
    }
359396
public static String getFileContent(String fileContent,String encoding){
		String fc = "";
		try {
			fc = new String(SDKUtil.inflater(SecureUtil.base64Decode(fileContent.getBytes())),encoding);
		} catch (UnsupportedEncodingException e) {
			LogUtil.writeErrorLog(e.getMessage(), e);
		} catch (IOException e) {
			LogUtil.writeErrorLog(e.getMessage(), e);
		}
		return fc;
	}
1209241
public static InputStream getContentStream(String stringUrl) throws MalformedURLException, IOException {
        URL url = new URL(stringUrl);
        
        URLConnection urlConnection = url.openConnection();
        
        InputStream is = urlConnection.getInputStream();
        if ("gzip".equals(urlConnection.getContentEncoding())) {
           is = new GZIPInputStream(is);
        }

        return is;
    }
57950
public function getContentEncoding() {
        if (!isset($this->metadata[OSSHeaders::CONTENT_ENCODING])) {
            return null;
        }
        return $this->metadata[OSSHeaders::CONTENT_ENCODING];
    }
51072
public static ContentSource getInputContentSource(Configuration conf) 
    throws URISyntaxException, XccConfigException, IOException {
        String host = conf.getStrings(INPUT_HOST)[0];
        if (host == null || host.isEmpty()) {
            throw new IllegalArgumentException(INPUT_HOST + 
                    " is not specified.");
        }
        
        return getInputContentSource(conf, host);
    }
886902
public byte[] getContent() throws TLVParserException {
        byte[] content = this.content;
        if (!children.isEmpty()) {
            for (TLVElement child : children) {
                content = Util.join(content, child.encodeHeader());
                content = Util.join(content, child.getContent());
            }
        }
        return content;
    }
1025125
public static String getString(byte[] contentBytes, Charset charset, boolean isGetCharsetFromContent) throws IOException {
		if (null == contentBytes) {
			return null;
		}

		if (null == charset) {
			charset = CharsetUtil.CHARSET_UTF_8;
		}
		String content = new String(contentBytes, charset);
		if (isGetCharsetFromContent) {
			final String charsetInContentStr = ReUtil.get(META_CHARSET_PATTERN, content, 1);
			if (StrUtil.isNotBlank(charsetInContentStr)) {
				Charset charsetInContent = null;
				try {
					charsetInContent = Charset.forName(charsetInContentStr);
				} catch (Exception e) {
					if (StrUtil.containsIgnoreCase(charsetInContentStr, "utf-8") || StrUtil.containsIgnoreCase(charsetInContentStr, "utf8")) {
						charsetInContent = CharsetUtil.CHARSET_UTF_8;
					} else if (StrUtil.containsIgnoreCase(charsetInContentStr, "gbk")) {
						charsetInContent = CharsetUtil.CHARSET_GBK;
					}
					// ignore
				}
				if (null != charsetInContent && false == charset.equals(charsetInContent)) {
					content = new String(contentBytes, charsetInContent);
				}
			}
		}
		return content;
	}
928525
public static Element getContentElementByUrl(String url) throws Exception {
//        HttpRequest request = new HttpRequest(url);
        String html = okHttpRequester.getResponse(url).html();
        return getContentElementByHtml(html, url);
    }
47606
public String getContentAsString() {
		if (contentAsString == null) {
			contentAsString = new String(rawContent,
					UriComponentEncoder.UTF8_CHARSET);
		}
		return contentAsString;
	}
646489
protected String getContentAsString(CmsFile file) throws CmsException {

        CmsProperty p = m_cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true);
        String e = p.getValue();
        if (e == null) {
            e = OpenCms.getSystemInfo().getDefaultEncoding();
        }
        return CmsEncoder.createString(file.getContents(), e);
    }
475764
public static String getContent(String stringUrl, Map<String, String> parameters)
      throws IOException {
    return getContent(stringUrl, parameters, null);
  }
680807
@Override
    public URI getContentDigest() {

        LOGGER.debug("getContentDigest getting digest info");
        try {
            // Determine which digest algorithm to use
            final String algorithm = hasDescriptionProperty(DEFAULT_DIGEST_ALGORITHM) ? property2values.apply(
                getDescriptionProperty(DEFAULT_DIGEST_ALGORITHM)).findFirst().get().getString()
                : ContentDigest.DEFAULT_ALGORITHM;
            final String algorithmWithoutStringType = algorithm.replace(FIELD_DELIMITER + XSDstring.getURI(), "");

            if (hasDescriptionProperty(CONTENT_DIGEST)) {
                // Select the stored digest that matches the digest algorithm
                final Optional<Value> digestValue = property2values.apply(getDescriptionProperty(CONTENT_DIGEST))
                        .filter(digest -> {
                        try {
                            final URI digestUri = URI.create(digest.getString());
                            return algorithmWithoutStringType.equalsIgnoreCase(ContentDigest.getAlgorithm(digestUri));

                        } catch (final RepositoryException e) {
                            LOGGER.warn("Exception thrown when getting digest property {}, {}", digest, e.getMessage());
                            return false;
                        }
                    }).findFirst();

                // Success, return the digest value
                if (digestValue.isPresent()) {
                    return URI.create(digestValue.get().getString());
                }
            }
            LOGGER.warn("No digest value was found to match the algorithm: {}", algorithmWithoutStringType);
        } catch (final RepositoryException e) {
            LOGGER.warn("Could not get content digest: {}", e.getMessage());
        }

        return ContentDigest.missingChecksum();
    }