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

Method parse

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

Parses the HTTP payload and returns a result body element. @param type media type @param encoding content encoding @return body element @throws IOException I/O exception @throws QueryException query exception

(final MediaType type, final String encoding)

Source from the content-addressed store, hash-verified

71 * @throws QueryException query exception
72 */
73 FNode parse(final MediaType type, final String encoding) throws IOException, QueryException {
74 final FBuilder body;
75 if(type.isMultipart()) {
76 // multipart response
77 final byte[] boundary = boundary(type);
78 body = FElem.build(Q_HTTP_MULTIPART).attr(Q_BOUNDARY, boundary);
79 final GNodeList parts = new GNodeList();
80 extractParts(concat(DASHES, boundary), parts);
81 for(final GNode node : parts) body.node(node);
82 } else {
83 // single part response
84 body = FElem.build(Q_HTTP_BODY);
85 if(payloads != null) {
86 final InputStream in = GZIP.equals(encoding) ? new GZIPInputStream(input) : input;
87 payloads.add(parse(BufferInput.get(in).content(), type));
88 }
89 }
90 return body.attr(Q_MEDIA_TYPE, type.type()).finish();
91 }
92
93 /**
94 * Returns all payloads.

Callers 2

getResponseMethod · 0.95
extractPartMethod · 0.95

Calls 15

boundaryMethod · 0.95
buildMethod · 0.95
extractPartsMethod · 0.95
nodeMethod · 0.95
getMethod · 0.95
attrMethod · 0.95
valueMethod · 0.95
isMultipartMethod · 0.80
addMethod · 0.65
typeMethod · 0.65
getMethod · 0.65
attrMethod · 0.45

Tested by

no test coverage detected