/** * Returns the request line. * * @param conn the {@link HttpConnection connection} used to execute * this HTTP method * * @return The request line. */ private String getRequestLine(HttpConnection conn) { return HttpMethodBase.generateRequestLine(conn, getName(), getPath(), getQueryString(), this.effectiveVersion.toString()); }
private RemoteConnectorRequestImpl(String url, HttpMethodBase method) { this.url = url; this.method = method; this.methodName = method.getName(); }
public String getName() { return this.method == null ? null : this.method.getName(); }
private RemoteConnectorRequestImpl(String url, HttpMethodBase method) { this.url = url; this.method = method; this.methodName = method.getName(); }
public String getName() { return method == null ? null : method.getName(); }
public HttpMethod getMethod() { return HttpMethod.valueOf(this.httpMethod.getName()); }
public String toString() { StringBuilder sb = new StringBuilder(getClass().getSimpleName()); sb.append("[Method=").append(method.getName()); sb.append("\n\tHTTP version=").append(method.getEffectiveVersion()); sb.append("\n\tstatus code=").append(method.getStatusCode()); sb.append("\n\tpath=").append(method.getPath()); sb.append("\n\tquery string=").append(method.getQueryString()); sb.append("\n\tresponse charset=").append(getResponseCharset()); Header[] responseHeaders = method.getResponseHeaders(); sb.append("\n\tresponse headers="); for (Header header : responseHeaders) { sb.append(header.toExternalForm()); } sb.append("]"); return sb.toString(); } }
/** * Sends an HTTP request * * @param method an HTTP method * @param auth true to request with authentication, false to request without * @return HTTP status code * @throws IOException if an error occurred during the HTTP request */ public int executeMethod(HttpMethodBase method, boolean auth) throws IOException { log.trace("{} {}", method.getName(), method.getURI()); int status = getHttpClient(auth).executeMethod(method); log.trace("{} {}", status, HttpStatus.getStatusText(status)); return status; } }
/** * adding OAuth authorization headers to a httpMethod * * @param httpMethod method which wants to add Authorization header */ private void setAuthorizationHeader(HttpMethodBase httpMethod) throws IdentityProvisioningException { boolean isDebugEnabled = log.isDebugEnabled(); String accessToken = authenticate(); if (StringUtils.isNotBlank(accessToken)) { httpMethod.setRequestHeader(SalesforceConnectorConstants.AUTHORIZATION_HEADER_NAME, SalesforceConnectorConstants.AUTHORIZATION_HEADER_OAUTH + " " + accessToken); if (isDebugEnabled) { log.debug("Setting authorization header for method : " + httpMethod.getName() + " as follows,"); Header authorizationHeader = httpMethod .getRequestHeader(SalesforceConnectorConstants.AUTHORIZATION_HEADER_NAME); log.debug(authorizationHeader.getName() + ": " + authorizationHeader.getValue()); } } else { throw new IdentityProvisioningException("Authentication failed"); } }
static public void showHttpRequestInfo(Formatter f, HttpMethodBase m) { f.format("HttpClient request %s %s %n", m.getName(), m.getPath()); f.format(" do Authentication=%s%n", m.getDoAuthentication()); f.format(" follow Redirects =%s%n", m.getFollowRedirects()); f.format(" effectiveVersion =%s%n", m.getEffectiveVersion()); f.format(" hostAuthState =%s%n", m.getHostAuthState()); HttpMethodParams p = m.getParams(); f.format(" cookie policy =%s%n", p.getCookiePolicy()); f.format(" http version =%s%n", p.getVersion()); f.format(" timeout (msecs) =%d%n", p.getSoTimeout()); f.format(" virtual host =%s%n", p.getVirtualHost()); f.format("Request Headers = %n"); Header[] heads = m.getRequestHeaders(); for(int i = 0;i < heads.length;i++) f.format(" %s", heads[i]); f.format("%n"); }
String methodName = method.getName();
private boolean checkStatusCode(URL url, HttpMethodBase method) throws IOException { int status = method.getStatusCode(); if (status == HttpStatus.SC_OK) { return true; } // IVY-1328: some servers return a 204 on a HEAD request if ("HEAD".equals(method.getName()) && (status == 204)) { return true; } Message.debug("HTTP response status: " + status + " url=" + url); if (status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) { Message.warn("Your proxy requires authentication."); } else if (String.valueOf(status).startsWith("4")) { Message.verbose("CLIENT ERROR: " + method.getStatusText() + " url=" + url); } else if (String.valueOf(status).startsWith("5")) { Message.error("SERVER ERROR: " + method.getStatusText() + " url=" + url); } return false; }
/** * Returns the request line. * * @param conn the {@link HttpConnection connection} used to execute * this HTTP method * * @return The request line. */ private String getRequestLine(HttpConnection conn) { return HttpMethodBase.generateRequestLine(conn, getName(), getPath(), getQueryString(), this.effectiveVersion.toString()); }
/** * Returns the request line. * * @param conn the {@link HttpConnection connection} used to execute * this HTTP method * * @return The request line. */ private String getRequestLine(HttpConnection conn) { return HttpMethodBase.generateRequestLine(conn, getName(), getPath(), getQueryString(), this.effectiveVersion.toString()); }
/** * Returns the request line. * * @param conn the {@link HttpConnection connection} used to execute * this HTTP method * * @return The request line. */ private String getRequestLine(HttpConnection conn) { return HttpMethodBase.generateRequestLine(conn, getName(), getPath(), getQueryString(), this.effectiveVersion.toString()); }
/** * Returns the request line. * * @param conn the {@link HttpConnection connection} used to execute * this HTTP method * * @return The request line. */ private String getRequestLine(HttpConnection conn) { return HttpMethodBase.generateRequestLine(conn, getName(), getPath(), getQueryString(), this.effectiveVersion.toString()); }
/** * Returns the request line. * * @param conn the {@link HttpConnection connection} used to execute * this HTTP method * * @return The request line. */ private String getRequestLine(HttpConnection conn) { return HttpMethodBase.generateRequestLine(conn, getName(), getPath(), getQueryString(), this.effectiveVersion.toString()); }
throw (IOException)new IOException(httpMethod.getName()+' '+url.toExternalForm()+" failed").initCause(e);
OAuthMessage message; try { message = new OAuthMessage(method.getName(), method.getURI().toString(), params.entrySet()); message.sign(accessor);
throw new RemoteStorageException( "Unexpected response code while executing " + method.getName() + " method [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteURL.toString() + "\"]. Expected: \"SUCCESS (200)\". Received: "