MCPcopy Create free account
hub / github.com/BaseXdb/basex / prepare

Method prepare

basex-core/src/main/java/org/basex/util/http/Payload.java:345–357  ·  view source on GitHub ↗

Returns a normalized payload. @param body body @param type media type @return content @throws IOException I/O exception

(final byte[] body, final MediaType type)

Source from the content-addressed store, hash-verified

343 * @throws IOException I/O exception
344 */
345 private static IOContent prepare(final byte[] body, final MediaType type) throws IOException {
346 byte[] data = body;
347 final boolean xml = type.isXml(), text = type.isText();
348 if(xml || text) {
349 // convert text to UTF8; skip redundant XML declaration
350 data = new NewlineInput(new IOContent(body), type.parameter(CHARSET)).content();
351 if(xml && startsWith(data, DECLSTART)) {
352 final int d = indexOf(data, DECLEND, DECLSTART.length);
353 if(d != -1) data = substring(data, d + DECLEND.length);
354 }
355 }
356 return new IOContent(data);
357 }
358}

Callers 1

valueMethod · 0.95

Calls 7

isXmlMethod · 0.80
isTextMethod · 0.80
contentMethod · 0.45
parameterMethod · 0.45
startsWithMethod · 0.45
indexOfMethod · 0.45
substringMethod · 0.45

Tested by

no test coverage detected