/** * Returns the dataEncoding or the default if no dataEncoding was provided. * * @return the value of the dataEncoding or DEFAULT_ENCODING */ public String getDataEncodingWithDefault() { return getDataEncodingWithDefault(DEFAULT_ENCODING); }
/** * Gets the responseData of the SampleResult object as a String * * @return the responseData value as a String, converted according to the encoding */ public String getResponseDataAsString() { try { if(responseDataAsString == null) { responseDataAsString= new String(responseData,getDataEncodingWithDefault()); } return responseDataAsString; } catch (UnsupportedEncodingException e) { log.warn("Using platform default as "+getDataEncodingWithDefault()+" caused "+e); return new String(responseData,Charset.defaultCharset()); // N.B. default charset is used deliberately here } }
/** * Sets the responseData attribute of the SampleResult object. * Should only be called after setting the dataEncoding (if necessary) * * @param response * the new responseData value (String) * * @deprecated - only intended for use from BeanShell code */ @Deprecated public void setResponseData(String response) { responseDataAsString = null; try { responseData = response.getBytes(getDataEncodingWithDefault()); } catch (UnsupportedEncodingException e) { log.warn("Could not convert string, using default encoding. "+e.getLocalizedMessage()); responseData = response.getBytes(Charset.defaultCharset()); // N.B. default charset is used deliberately here } }
final String responseData = (String) subItem; if (responseData.length() > 0) { final String dataEncoding = res.getDataEncodingWithDefault(); try { res.setResponseData(responseData.getBytes(dataEncoding));
res.setResponseData(getResponseData().getBytes(res.getDataEncodingWithDefault())); } catch (UnsupportedEncodingException exc) { throw new RuntimeException("Failed to get response data", exc);
try { if (SampleResult.TEXT.equals(res.getDataType())){ writer.setValue(new String(res.getResponseData(), res.getDataEncodingWithDefault())); } else { writer.setValue("Non-TEXT response data, cannot record: (" + res.getDataType() + ")");
text.append(sample.getDataEncodingWithDefault());