final HttpURLConnection conn = (HttpURLConnection)connectionFactory.openConnection(url); final boolean doOutput = op.getDoOutput(); conn.setRequestMethod(op.getType().toString()); conn.setInstanceFollowRedirects(false); if (restCsrfCustomHeader != null && !restCsrfMethodsToIgnore.contains(op.getType().name())) { switch (op.getType()) {
Param<?,?>[] getAuthParameters(final HttpOpParam.Op op) throws IOException { List<Param<?,?>> authParams = Lists.newArrayList(); // Skip adding delegation token for token operations because these // operations require authentication. Token<?> token = null; if (!op.getRequireAuth()) { token = getDelegationToken(); } if (token != null) { authParams.add(new DelegationParam(token.encodeToUrlString())); } else { UserGroupInformation userUgi = ugi; UserGroupInformation realUgi = userUgi.getRealUser(); if (realUgi != null) { // proxy user authParams.add(new DoAsParam(userUgi.getShortUserName())); userUgi = realUgi; } authParams.add(new UserParam(userUgi.getShortUserName())); } return authParams.toArray(new Param<?,?>[0]); }
if (code != op.getExpectedHttpResponseCode()) { final Map<?, ?> m; try { } catch(Exception e) { throw new IOException("Unexpected HTTP response: code=" + code + " != " + op.getExpectedHttpResponseCode() + ", " + op.toQueryString() + ", message=" + conn.getResponseMessage(), e); + op.getExpectedHttpResponseCode() + ", " + op.toQueryString() + ", message=" + conn.getResponseMessage()); } else if (m.get(RemoteException.class.getSimpleName()) == null) {
final URL url = webhdfs.toUrl(op, dir); final HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(op.getType().toString()); conn.connect(); assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode()); final URL url = webhdfs.toUrl(op, dir); final HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(op.getType().toString()); conn.connect(); assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode()); final URL url = webhdfs.toUrl(op, dir); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(op.getType().toString()); conn.setDoOutput(false); conn.setInstanceFollowRedirects(false); conn.setRequestMethod(op.getType().toString()); conn.setDoOutput(op.getDoOutput()); conn.connect(); assertEquals(HttpServletResponse.SC_BAD_REQUEST, conn.getResponseCode()); final URL url = webhdfs.toUrl(op, file); final HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(op.getType().toString()); conn.connect(); URL url = webhdfs.toUrl(op, path);
final HttpURLConnection conn = connect(url); if (!op.getDoOutput()) { validateResponse(op, conn, false); if (op.getRequireAuth() || !replaceExpiredDelegationToken()) { throw it;
if (op.getRedirect() && !redirected) { final HttpOpParam.Op redirectOp = HttpOpParam.TemporaryRedirectOp.valueOf(op); final HttpURLConnection conn = connect(redirectOp, url); if (conn.getResponseCode() == op.getExpectedHttpResponseCode()) { return conn; final HttpURLConnection conn = connect(op, url); if (!op.getDoOutput()) { validateResponse(op, conn, false);
if (op.getRedirect() && !redirected) { final HttpOpParam.Op redirectOp = HttpOpParam.TemporaryRedirectOp.valueOf(op); final HttpURLConnection conn = connect(redirectOp, url); if (conn.getResponseCode() == op.getExpectedHttpResponseCode()) { return conn;
if (op.getRequireAuth() || !replaceExpiredDelegationToken()) { throw it;
if (op.getRedirect() && !redirected) { final HttpOpParam.Op redirectOp = HttpOpParam.TemporaryRedirectOp.valueOf(op); final HttpURLConnection conn = connect(redirectOp, url); if (conn.getResponseCode() == op.getExpectedHttpResponseCode()) { return conn;
final HttpURLConnection conn = connect(url); if (!op.getDoOutput()) { validateResponse(op, conn, false); if (op.getRequireAuth() || !replaceExpiredDelegationToken()) { throw it;
delegationQuery = "&" + new DelegationParam(t.encodeToUrlString()); final String query = op.toQueryString() + delegationQuery + "&" + new NamenodeAddressParam(namenode) + Param.toSortedString("&", parameters);
try { conn = (HttpURLConnection)url.openConnection(); conn.setRequestMethod(op.getType().toString()); conn.setDoOutput(op.getDoOutput()); conn.setInstanceFollowRedirects(true);
if (code != op.getExpectedHttpResponseCode()) { final Map<?, ?> m; try { } catch(Exception e) { throw new IOException("Unexpected HTTP response: code=" + code + " != " + op.getExpectedHttpResponseCode() + ", " + op.toQueryString() + ", message=" + conn.getResponseMessage(), e); + op.getExpectedHttpResponseCode() + ", " + op.toQueryString() + ", message=" + conn.getResponseMessage()); } else if (m.get(RemoteException.class.getSimpleName()) == null) {
try { conn = (HttpURLConnection)url.openConnection(); conn.setRequestMethod(op.getType().toString()); conn.setDoOutput(op.getDoOutput()); conn.setInstanceFollowRedirects(true);
delegationQuery = "&" + new DelegationParam(t.encodeToUrlString()); final String query = op.toQueryString() + delegationQuery + "&" + new NamenodeAddressParam(namenode) + Param.toSortedString("&", parameters);
if (code != op.getExpectedHttpResponseCode()) { final Map<?, ?> m; try { } catch(Exception e) { throw new IOException("Unexpected HTTP response: code=" + code + " != " + op.getExpectedHttpResponseCode() + ", " + op.toQueryString() + ", message=" + conn.getResponseMessage(), e); + op.getExpectedHttpResponseCode() + ", " + op.toQueryString() + ", message=" + conn.getResponseMessage()); } else if (m.get(RemoteException.class.getSimpleName()) == null) {
+ (encodedFSPath == null ? "/" : makeQualified(encodedFSPath).toUri().getRawPath()); final String query = op.toQueryString() + Param.toSortedString("&", getAuthParameters(op)) + Param.toSortedString("&", parameters);
final HttpURLConnection conn = (HttpURLConnection)connectionFactory.openConnection(url); final boolean doOutput = op.getDoOutput(); conn.setRequestMethod(op.getType().toString()); conn.setInstanceFollowRedirects(false); switch (op.getType()) {
final URL url = webhdfs.toUrl(op, file); final HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(op.getType().toString()); conn.connect();
final HttpURLConnection conn = (HttpURLConnection)connectionFactory.openConnection(url); final boolean doOutput = op.getDoOutput(); conn.setRequestMethod(op.getType().toString()); conn.setInstanceFollowRedirects(false); switch (op.getType()) {