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

Method payload

basex-core/src/main/java/org/basex/util/http/Client.java:232–259  ·  view source on GitHub ↗

Returns the payload. @param request request data @return input stream @throws IOException I/O exception

(final Request request)

Source from the content-addressed store, hash-verified

230 * @throws IOException I/O exception
231 */
232 public static byte[] payload(final Request request) throws IOException {
233 final ArrayOutput out = new ArrayOutput();
234 if(request.isMultipart) {
235 final String boundary = request.boundary();
236 for(final Part part : request.parts) {
237 // write content to cache
238 final ArrayOutput ao = new ArrayOutput();
239 writePayload(part.contents, part.attributes, ao);
240
241 // write boundary preceded by "--"
242 out.write(Token.concat("--", boundary, CRLF));
243
244 // write headers
245 for(final Entry<String, String> header : part.headers.entrySet())
246 writeHeader(header.getKey(), header.getValue(), out);
247 if(!part.headers.containsKey(CONTENT_TYPE))
248 writeHeader(CONTENT_TYPE, part.attributes.get(SerializerOptions.MEDIA_TYPE.name()), out);
249
250 out.write(CRLF);
251 out.write(ao.finish());
252 out.write(CRLF);
253 }
254 out.write(Token.concat("--", boundary, "--", CRLF));
255 } else {
256 writePayload(request.payload, request.payloadAtts, out);
257 }
258 return out.finish();
259 }
260
261 /**
262 * Writes a single header.

Callers 2

writeMethod · 0.95
sendMethod · 0.95

Calls 10

writePayloadMethod · 0.95
writeMethod · 0.95
concatMethod · 0.95
writeHeaderMethod · 0.95
finishMethod · 0.95
getKeyMethod · 0.80
getMethod · 0.65
nameMethod · 0.65
boundaryMethod · 0.45
getValueMethod · 0.45

Tested by 1

writeMethod · 0.76