public static String buildUrlWithParams(/*@Nullable*/String userLocale, String host, String path, /*@Nullable*/String/*@Nullable*/[] params) { return buildUri(host, path) + "?" + encodeUrlParams(userLocale, params); }
public <ArgT> HttpRequestor.Uploader uploadStyle(String host, String path, ArgT arg, boolean noAuth, StoneSerializer<ArgT> argSerializer) throws DbxException { String uri = DbxRequestUtil.buildUri(host, path); List<HttpRequestor.Header> headers = new ArrayList<HttpRequestor.Header>(); if (!noAuth) { addAuthHeaders(headers); } addUserLocaleHeader(headers, requestConfig); addPathRootHeader(headers, this.pathRoot); headers.add(new HttpRequestor.Header("Content-Type", "application/octet-stream")); headers = DbxRequestUtil.addUserAgentHeader(headers, requestConfig, USER_AGENT_ID); headers.add(new HttpRequestor.Header("Dropbox-API-Arg", headerSafeJson(argSerializer, arg))); try { return requestConfig.getHttpRequestor().startPost(uri, headers); } catch (IOException ex) { throw new NetworkIOException(ex); } }
/** * Convenience function for making HTTP POST requests. Like startPostNoAuth but takes byte[] instead of params. */ public static HttpRequestor.Response startPostRaw(DbxRequestConfig requestConfig, String sdkUserAgentIdentifier, String host, String path, byte[] body, /*@Nullable*/List<HttpRequestor.Header> headers) throws NetworkIOException { String uri = buildUri(host, path); headers = copyHeaders(headers); headers = addUserAgentHeader(headers, requestConfig, sdkUserAgentIdentifier); headers.add(new HttpRequestor.Header("Content-Length", Integer.toString(body.length))); try { HttpRequestor.Uploader uploader = requestConfig.getHttpRequestor().startPost(uri, headers); try { uploader.upload(body); return uploader.finish(); } finally { uploader.close(); } } catch (IOException ex) { throw new NetworkIOException(ex); } }