public ApplicationLinkRequest addHeader(final String s, final String s1) { wrappedRequest.addHeader(s, s1); return this; }
public ApplicationLinkRequest addHeader(final String s, final String s1) { wrappedRequest.addHeader(s, s1); return this; }
@Override public ApplicationLinkRequest addHeader(String headerName, String headerValue) { delegateRequest.addHeader(headerName, headerValue); return this; }
/** * Execute a Get Request on the {@link ApplicationLink} given * * @param url the target services url * @param headers request headers * @param timeout timeout in milliseconds * @return the {@link RestResponse} response * @throws com.atlassian.applinks.api.CredentialsRequiredException * in case the {@link ApplicationLink} credentials are outdated */ private RestResponse executeGetRequest(String url, Map<String, String> headers, int timeout) throws CredentialsRequiredException { ApplicationLinkRequestFactory requestFactory = getAuthenticatedRequestFactory(); ApplicationLinkRequest request = requestFactory.createRequest(Request.MethodType.GET, url); for (Map.Entry<String, String> header : headers.entrySet()) { request.addHeader(header.getKey(), header.getValue()); } return executeRequest(request, requestFactory, timeout); }
@Override protected void modifyRequest(ApplicationLinkRequest request) { RequestFilePart requestFilePart = new RequestFilePart(attachment.getMimetype(), attachment.getFilename(), attachmentFile, "file"); request.setFiles(ImmutableList.of(requestFilePart)); request.addHeader("X-Atlassian-Token", "nocheck"); } });
private AuthorisationUriAwareRequest buildRequest(@Nonnull ApplicationLinkRequestFactory requestFactory) throws CredentialsRequiredException { ApplicationLinkRequest request = requestFactory .createRequest(methodType, url.toString()) .setHeader(HttpHeaders.ACCEPT, accept) .addHeader(OVERRIDE_HEADER_NAME, OVERRIDE_HEADER_VALUE) .setConnectionTimeout(connectionTimeoutMillis) .setSoTimeout(socketTimeoutMillis) .setFollowRedirects(followRedirects); if (body != null && isMutatingMethodType()) { request.setEntity(body); request.setHeader(HttpHeaders.CONTENT_TYPE, contentType); } for (Map.Entry<String, String> header : headers.entrySet()) { request.setHeader(header.getKey(), header.getValue()); } return new DefaultAuthorisationUriAwareRequest(request, requestFactory); }
request.addHeader("Content-Type", cType + "; charset=" + charset.name());
request.addHeader("Content-Type", cType + "; charset=" + charset.name());
@Nullable @Override public <T> T execute(@Nonnull HttpRequest httpRequest, @Nonnull HttpResponseProcessor<T> responseProcessor) throws StashException { final ApplicationLinkRequestFactory requestFactory = (httpRequest.isAnonymous() ? anonymousRequestFactory : authenticatedRequestFactory); String requestUrl = httpRequest.getUrl(); Request.MethodType methodType = Request.MethodType.valueOf(httpRequest.getMethod().name()); try { final ApplicationLinkRequest request = requestFactory.createRequest(methodType, requestUrl); request.setHeader("Content-Type", "application/json"); request.addHeader("X-Atlassian-Token", "no-check"); // prevent XSRF checks if (methodType != Request.MethodType.GET && httpRequest.getPayload() != null) { request.setRequestBody(httpRequest.getPayload()); } request.setSoTimeout((int) TimeUnit.SECONDS.toMillis(STASH_REST_SOCKET_TIMEOUT)); return request.execute(new StashApplinkResponseHandler<>(requestFactory, applicationLink, responseProcessor)); } catch (ResponseException e) { throw new StashException(e); } catch (CredentialsRequiredException e) { throw new StashCredentialsRequiredException(e, applicationLink); } }