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

Method sendRequest

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

Sends an HTTP request and returns the response. @param href URL to send the request to (can be empty string) @param request request data @param bodies request body @return HTTP response @throws QueryException query exception

(final byte[] href, final XNode request, final Value bodies)

Source from the content-addressed store, hash-verified

62 * @throws QueryException query exception
63 */
64 public Value sendRequest(final byte[] href, final XNode request, final Value bodies)
65 throws QueryException {
66
67 final Request req = new RequestParser(info).parse(request, bodies);
68 final URI uri = uri(href, req);
69 final String mediaType = req.attribute(OVERRIDE_MEDIA_TYPE);
70 final String status = req.attribute(STATUS_ONLY);
71 final boolean body = status == null || Strings.isFalse(status);
72
73 final MainOptions mopts = new MainOptions(options);
74 try {
75 mopts.set(MainOptions.CSVPARSER,
76 assign(new CsvParserOptions(mopts.get(MainOptions.CSVPARSER)), req.attribute(CSV)));
77 mopts.set(MainOptions.JSONPARSER,
78 assign(new JsonParserOptions(mopts.get(MainOptions.JSONPARSER)), req.attribute(JSON)));
79 mopts.set(MainOptions.HTMLPARSER,
80 assign(new HtmlOptions(mopts.get(MainOptions.HTMLPARSER)), req.attribute(HTML)));
81
82 return new Response(info, mopts).getResponse(send(uri, req), body, mediaType);
83 } catch(final IOException ex) {
84 throw HC_ERROR_X.get(info, ex);
85 }
86 }
87
88 /**
89 * Assigns parser options.

Callers 1

valueMethod · 0.45

Calls 9

uriMethod · 0.95
attributeMethod · 0.95
isFalseMethod · 0.95
assignMethod · 0.95
sendMethod · 0.95
getResponseMethod · 0.80
setMethod · 0.65
getMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected