java.net.HttpURLConnection#HTTP_MOVED_PERM源码实例Demo

下面列出了java.net.HttpURLConnection#HTTP_MOVED_PERM 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cordova-amazon-fireos   文件: ResponseHeaders.java
/**
 * Returns true if this response can be stored to later serve another
 * request.
 */
public boolean isCacheable(RequestHeaders request) {
  // Always go to network for uncacheable response codes (RFC 2616, 13.4),
  // This implementation doesn't support caching partial content.
  int responseCode = headers.getResponseCode();
  if (responseCode != HttpURLConnection.HTTP_OK
      && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE
      && responseCode != HttpURLConnection.HTTP_MULT_CHOICE
      && responseCode != HttpURLConnection.HTTP_MOVED_PERM
      && responseCode != HttpURLConnection.HTTP_GONE) {
    return false;
  }

  // Responses to authorized requests aren't cacheable unless they include
  // a 'public', 'must-revalidate' or 's-maxage' directive.
  if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) {
    return false;
  }

  if (noStore) {
    return false;
  }

  return true;
}
 
源代码2 项目: tools   文件: ListedLicenses.java
public static String getNestedURL(String stringUrl) throws MalformedURLException {
	URL url = new URL(stringUrl);
	try {
		HttpURLConnection con = (HttpURLConnection) url.openConnection();
		con.setInstanceFollowRedirects(false);
		con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36");
		con.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
		con.addRequestProperty("Referer", "https://www.google.com/");
		con.connect();
		int resultCode = con.getResponseCode();
		if (resultCode == HttpURLConnection.HTTP_SEE_OTHER
				|| resultCode == HttpURLConnection.HTTP_MOVED_PERM
				|| resultCode == HttpURLConnection.HTTP_MOVED_TEMP) {
			String Location = con.getHeaderField("Location");
			if (Location.startsWith("/")) {
				Location = url.getProtocol() + "://" + url.getHost() + Location;
			}
			return getNestedURL(Location);
		}
	} catch (Exception e) {
		System.out.println(e.getMessage());
	}
	return url.toString();
}
 
源代码3 项目: wildfly-samples   文件: ResponseHeaders.java
/**
 * Returns true if this response can be stored to later serve another
 * request.
 */
public boolean isCacheable(RequestHeaders request) {
  // Always go to network for uncacheable response codes (RFC 2616, 13.4),
  // This implementation doesn't support caching partial content.
  int responseCode = headers.getResponseCode();
  if (responseCode != HttpURLConnection.HTTP_OK
      && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE
      && responseCode != HttpURLConnection.HTTP_MULT_CHOICE
      && responseCode != HttpURLConnection.HTTP_MOVED_PERM
      && responseCode != HttpURLConnection.HTTP_GONE) {
    return false;
  }

  // Responses to authorized requests aren't cacheable unless they include
  // a 'public', 'must-revalidate' or 's-maxage' directive.
  if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) {
    return false;
  }

  if (noStore) {
    return false;
  }

  return true;
}
 
源代码4 项目: materialup   文件: UrlUtil.java
public static String getFinalURL(String url) throws IOException {
    HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
    con.setInstanceFollowRedirects(false);
    con.connect();
    con.getInputStream();

    if (con.getResponseCode() == HttpURLConnection.HTTP_MOVED_PERM || con.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP) {
        String redirectUrl = con.getHeaderField("Location");
        if (TextUtils.isEmpty(redirectUrl)) {
            return url;
        }
        if (redirectUrl.startsWith(Api.getEndpoint())) {
            return getFinalURL(redirectUrl);
        }
        return redirectUrl;
    }
    return url;
}
 
/**
 * Returns true if this response can be stored to later serve another
 * request.
 */
public boolean isCacheable(RequestHeaders request) {
  // Always go to network for uncacheable response codes (RFC 2616, 13.4),
  // This implementation doesn't support caching partial content.
  int responseCode = headers.getResponseCode();
  if (responseCode != HttpURLConnection.HTTP_OK
      && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE
      && responseCode != HttpURLConnection.HTTP_MULT_CHOICE
      && responseCode != HttpURLConnection.HTTP_MOVED_PERM
      && responseCode != HttpURLConnection.HTTP_GONE) {
    return false;
  }

  // Responses to authorized requests aren't cacheable unless they include
  // a 'public', 'must-revalidate' or 's-maxage' directive.
  if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) {
    return false;
  }

  if (noStore) {
    return false;
  }

  return true;
}
 
源代码6 项目: android-discourse   文件: ResponseHeaders.java
/**
 * Returns true if this response can be stored to later serve another
 * request.
 */
public boolean isCacheable(RequestHeaders request) {
    // Always go to network for uncacheable response codes (RFC 2616, 13.4),
    // This implementation doesn't support caching partial content.
    int responseCode = headers.getResponseCode();
    if (responseCode != HttpURLConnection.HTTP_OK && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE && responseCode != HttpURLConnection.HTTP_MULT_CHOICE && responseCode != HttpURLConnection.HTTP_MOVED_PERM && responseCode != HttpURLConnection.HTTP_GONE) {
        return false;
    }

    // Responses to authorized requests aren't cacheable unless they include
    // a 'public', 'must-revalidate' or 's-maxage' directive.
    if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) {
        return false;
    }

    if (noStore) {
        return false;
    }

    return true;
}
 
源代码7 项目: barcodescanner-lib-aar   文件: HttpHelper.java
public static URI unredirect(URI uri) throws IOException {
  if (!REDIRECTOR_DOMAINS.contains(uri.getHost())) {
    return uri;
  }
  URL url = uri.toURL();
  HttpURLConnection connection = safelyOpenConnection(url);
  connection.setInstanceFollowRedirects(false);
  connection.setDoInput(false);
  connection.setRequestMethod("HEAD");
  connection.setRequestProperty("User-Agent", "ZXing (Android)");
  try {
    int responseCode = safelyConnect(connection);
    switch (responseCode) {
      case HttpURLConnection.HTTP_MULT_CHOICE:
      case HttpURLConnection.HTTP_MOVED_PERM:
      case HttpURLConnection.HTTP_MOVED_TEMP:
      case HttpURLConnection.HTTP_SEE_OTHER:
      case 307: // No constant for 307 Temporary Redirect ?
        String location = connection.getHeaderField("Location");
        if (location != null) {
          try {
            return new URI(location);
          } catch (URISyntaxException e) {
            // nevermind
          }
        }
    }
    return uri;
  } finally {
    connection.disconnect();
  }
}
 
源代码8 项目: rapidminer-studio   文件: UrlFollower.java
/**
 * Checks if the connection is redirecting
 *
 * @param connection the connection to check
 * @return true if the response code is a redirect code
 *
 * @throws IOException if an error occurred connecting to the server.
 */
private static boolean isRedirecting(HttpURLConnection connection) throws IOException {
	switch (connection.getResponseCode()) {
		case HttpURLConnection.HTTP_MOVED_PERM:
		case HttpURLConnection.HTTP_MOVED_TEMP:
		case HttpURLConnection.HTTP_SEE_OTHER:
		case TEMPORARY_REDIRECT:
		case PERMANENT_REDIRECT:
			return true;
		default:
			return false;
	}
}
 
源代码9 项目: jus   文件: RedirectPolicy.java
@Override
public Request verifyRedirect(final Request request, NetworkResponse networkResponse) {
    Request res = null;
    if (networkResponse != null && networkResponse.headers != null
            && networkResponse.headers.get("location") != null && (
            networkResponse.statusCode == HttpURLConnection.HTTP_MULT_CHOICE
                    || networkResponse.statusCode == HttpURLConnection.HTTP_MOVED_PERM
                    || networkResponse.statusCode == HttpURLConnection.HTTP_MOVED_TEMP
                    || networkResponse.statusCode == HttpURLConnection.HTTP_SEE_OTHER
                    || networkResponse.statusCode == 307
                    || networkResponse.statusCode == 308

    )) {
        HttpUrl url = request.getUrl().resolve(networkResponse.headers.get("location"));
        if (networkResponse.statusCode == HttpURLConnection.HTTP_SEE_OTHER) {
            res = new Request(Request.Method.GET, url)
                    .setNetworkRequest(new NetworkRequest.Builder()
                            .addHeaders(request.getNetworkRequest().headers).build());
        } else {
            res = new Request(request.getMethod(), url)
                    .setNetworkRequest(request.getNetworkRequest());
        }
        res.setRetryPolicy(request.getRetryPolicy())
                .setRedirectPolicy(request.getRedirectPolicy())
                .addMarkerListener(new RequestListener.MarkerListener() {
                    @Override
                    public void onMarker(Marker marker, Object... args) {
                        request.addMarker(marker.name, args);
                    }
                });
    }
    return res;
}
 
源代码10 项目: android-apps   文件: HttpHelper.java
public static URI unredirect(URI uri) throws IOException {
  if (!REDIRECTOR_DOMAINS.contains(uri.getHost())) {
    return uri;
  }
  URL url = uri.toURL();

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setInstanceFollowRedirects(false);
  connection.setDoInput(false);
  connection.setRequestMethod("HEAD");
  connection.setRequestProperty("User-Agent", "ZXing (Android)");
  try {
    connection.connect();
    switch (connection.getResponseCode()) {
      case HttpURLConnection.HTTP_MULT_CHOICE:
      case HttpURLConnection.HTTP_MOVED_PERM:
      case HttpURLConnection.HTTP_MOVED_TEMP:
      case HttpURLConnection.HTTP_SEE_OTHER:
      case 307: // No constant for 307 Temporary Redirect ?
        String location = connection.getHeaderField("Location");
        if (location != null) {
          try {
            return new URI(location);
          } catch (URISyntaxException e) {
            // nevermind
          }
        }
    }
    return uri;
  } finally {
    connection.disconnect();
  }
}
 
源代码11 项目: BarcodeEye   文件: HttpHelper.java
public static URI unredirect(URI uri) throws IOException {
  if (!REDIRECTOR_DOMAINS.contains(uri.getHost())) {
    return uri;
  }
  URL url = uri.toURL();
  HttpURLConnection connection = safelyOpenConnection(url);
  connection.setInstanceFollowRedirects(false);
  connection.setDoInput(false);
  connection.setRequestMethod("HEAD");
  connection.setRequestProperty("User-Agent", "ZXing (Android)");
  try {
    int responseCode = safelyConnect(uri.toString(), connection);
    switch (responseCode) {
      case HttpURLConnection.HTTP_MULT_CHOICE:
      case HttpURLConnection.HTTP_MOVED_PERM:
      case HttpURLConnection.HTTP_MOVED_TEMP:
      case HttpURLConnection.HTTP_SEE_OTHER:
      case 307: // No constant for 307 Temporary Redirect ?
        String location = connection.getHeaderField("Location");
        if (location != null) {
          try {
            return new URI(location);
          } catch (URISyntaxException e) {
            // nevermind
          }
        }
    }
    return uri;
  } finally {
    connection.disconnect();
  }
}
 
public static URI unredirect(URI uri) throws IOException {
  if (!REDIRECTOR_DOMAINS.contains(uri.getHost())) {
    return uri;
  }
  URL url = uri.toURL();
  HttpURLConnection connection = safelyOpenConnection(url);
  connection.setInstanceFollowRedirects(false);
  connection.setDoInput(false);
  connection.setRequestMethod("HEAD");
  connection.setRequestProperty("User-Agent", "ZXing (Android)");
  try {
    int responseCode = safelyConnect(connection);
    switch (responseCode) {
      case HttpURLConnection.HTTP_MULT_CHOICE:
      case HttpURLConnection.HTTP_MOVED_PERM:
      case HttpURLConnection.HTTP_MOVED_TEMP:
      case HttpURLConnection.HTTP_SEE_OTHER:
      case 307: // No constant for 307 Temporary Redirect ?
        String location = connection.getHeaderField("Location");
        if (location != null) {
          try {
            return new URI(location);
          } catch (URISyntaxException e) {
            // nevermind
          }
        }
    }
    return uri;
  } finally {
    connection.disconnect();
  }
}
 
源代码13 项目: Popeens-DSub   文件: RESTMusicService.java
private boolean detectRedirect(Context context, URL originalUrl, HttpURLConnection connection) throws Exception {
	if(connection.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP || connection.getResponseCode() == HttpURLConnection.HTTP_MOVED_PERM) {
		String redirectLocation = connection.getHeaderField("Location");
		if(redirectLocation != null) {
			detectRedirect(context, originalUrl.toExternalForm(), redirectLocation);
			return true;
		}
	}

	detectRedirect(context, originalUrl, connection.getURL());
	return false;
}
 
源代码14 项目: Study_Android_Demo   文件: HttpHelper.java
public static URI unredirect(URI uri) throws IOException {
  if (!REDIRECTOR_DOMAINS.contains(uri.getHost())) {
    return uri;
  }
  URL url = uri.toURL();
  HttpURLConnection connection = safelyOpenConnection(url);
  connection.setInstanceFollowRedirects(false);
  connection.setDoInput(false);
  connection.setRequestMethod("HEAD");
  connection.setRequestProperty("User-Agent", "ZXing (Android)");
  try {
    int responseCode = safelyConnect(connection);
    switch (responseCode) {
      case HttpURLConnection.HTTP_MULT_CHOICE:
      case HttpURLConnection.HTTP_MOVED_PERM:
      case HttpURLConnection.HTTP_MOVED_TEMP:
      case HttpURLConnection.HTTP_SEE_OTHER:
      case 307: // No constant for 307 Temporary Redirect ?
        String location = connection.getHeaderField("Location");
        if (location != null) {
          try {
            return new URI(location);
          } catch (URISyntaxException e) {
            // nevermind
          }
        }
    }
    return uri;
  } finally {
    connection.disconnect();
  }
}
 
源代码15 项目: lams   文件: WebWindow.java
/**
 * check whether redirect is configured
 * @param response
 * @return
 */
private boolean redirectConfigured( WebResponse response ) {
	boolean isAutoredirect=getClient().getClientProperties().isAutoRedirect();
	boolean hasLocation=response.getHeaderField( "Location" ) != null;
	int responseCode=response.getResponseCode();
	boolean result=isAutoredirect
  	&& responseCode >= HttpURLConnection.HTTP_MOVED_PERM
  	&& responseCode <= HttpURLConnection.HTTP_MOVED_TEMP
  	&& hasLocation;
  return result;
}
 
源代码16 项目: dhis2-android-datacapture   文件: LoginProcessor.java
private static String prepareUrl(String initialUrl, String creds) {
    if (initialUrl.contains(HTTPS) || initialUrl.contains(HTTP)) {
        return initialUrl;
    }

    // try to use https
    Response response = tryToLogIn(HTTPS + initialUrl, creds);
    if (response.getCode() != HttpURLConnection.HTTP_MOVED_PERM) {
        return HTTPS + initialUrl;
    } else {
        return HTTP + initialUrl;
    }
}
 
源代码17 项目: Elasticsearch   文件: HttpDownloadHelper.java
private URLConnection openConnection(URL aSource) throws IOException {

            // set up the URL connection
            URLConnection connection = aSource.openConnection();
            // modify the headers
            // NB: things like user authentication could go in here too.
            if (hasTimestamp) {
                connection.setIfModifiedSince(timestamp);
            }

            // in case the plugin manager is its own project, this can become an authenticator
            boolean isSecureProcotol = "https".equalsIgnoreCase(aSource.getProtocol());
            boolean isAuthInfoSet = !Strings.isNullOrEmpty(aSource.getUserInfo());
            if (isAuthInfoSet) {
                if (!isSecureProcotol) {
                    throw new IOException("Basic auth is only supported for HTTPS!");
                }
                String basicAuth = Base64.encodeBytes(aSource.getUserInfo().getBytes(StandardCharsets.UTF_8));
                connection.setRequestProperty("Authorization", "Basic " + basicAuth);
            }

            if (connection instanceof HttpURLConnection) {
                ((HttpURLConnection) connection).setInstanceFollowRedirects(false);
                connection.setUseCaches(true);
                connection.setConnectTimeout(5000);
            }
            connection.setRequestProperty("ES-Version", Version.CURRENT.toString());
            connection.setRequestProperty("ES-Build-Hash", Build.CURRENT.hashShort());
            connection.setRequestProperty("User-Agent", "elasticsearch-plugin-manager");

            // connect to the remote site (may take some time)
            connection.connect();

            // First check on a 301 / 302 (moved) response (HTTP only)
            if (connection instanceof HttpURLConnection) {
                HttpURLConnection httpConnection = (HttpURLConnection) connection;
                int responseCode = httpConnection.getResponseCode();
                if (responseCode == HttpURLConnection.HTTP_MOVED_PERM ||
                        responseCode == HttpURLConnection.HTTP_MOVED_TEMP ||
                        responseCode == HttpURLConnection.HTTP_SEE_OTHER) {
                    String newLocation = httpConnection.getHeaderField("Location");
                    URL newURL = new URL(newLocation);
                    if (!redirectionAllowed(aSource, newURL)) {
                        return null;
                    }
                    return openConnection(newURL);
                }
                // next test for a 304 result (HTTP only)
                long lastModified = httpConnection.getLastModified();
                if (responseCode == HttpURLConnection.HTTP_NOT_MODIFIED
                        || (lastModified != 0 && hasTimestamp && timestamp >= lastModified)) {
                    // not modified so no file download. just return
                    // instead and trace out something so the user
                    // doesn't think that the download happened when it
                    // didn't
                    return null;
                }
                // test for 401 result (HTTP only)
                if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
                    String message = "HTTP Authorization failure";
                    throw new IOException(message);
                }
            }

            //REVISIT: at this point even non HTTP connections may
            //support the if-modified-since behaviour -we just check
            //the date of the content and skip the write if it is not
            //newer. Some protocols (FTP) don't include dates, of
            //course.
            return connection;
        }
 
源代码18 项目: jeka   文件: IvyFollowRedirectUrlHandler.java
private boolean checkRedirect(HttpURLConnection con) throws IOException {
    final int status = con.getResponseCode();
    return status == HttpURLConnection.HTTP_MOVED_TEMP
            || status == HttpURLConnection.HTTP_MOVED_PERM
            || status == HttpURLConnection.HTTP_SEE_OTHER;
}
 
源代码19 项目: cloudflare-scrape-Android   文件: Cloudflare.java
private void getVisitCookie() throws IOException, InterruptedException {
    ConnUrl = new URL(mUrl);
    mGetMainConn = (HttpURLConnection) ConnUrl.openConnection();
    mGetMainConn.setRequestMethod("GET");
    mGetMainConn.setConnectTimeout(CONN_TIMEOUT);
    mGetMainConn.setReadTimeout(CONN_TIMEOUT);
    if (!TextUtils.isEmpty(mUser_agent)){
        mGetMainConn.setRequestProperty("user-agent",mUser_agent);
    }
    mGetMainConn.setRequestProperty("accept",ACCEPT);
    mGetMainConn.setRequestProperty("referer", mUrl);
    if (mCookieList!=null&&mCookieList.size()>0){
        mGetMainConn.setRequestProperty("cookie",listToString(mCookieList));
    }
    mGetMainConn.setUseCaches(false);
    mGetMainConn.connect();
    switch (mGetMainConn.getResponseCode()){
        case HttpURLConnection.HTTP_OK:
            e("MainUrl","visit website success");
            mCookieList = mCookieManager.getCookieStore().getCookies();
            checkCookie(mCookieList);
            return;
        case HttpURLConnection.HTTP_MOVED_PERM:
        case HttpURLConnection.HTTP_MOVED_TEMP:
            hasNewUrl = true;
            mUrl = mGetMainConn.getHeaderField("Location");
            mCookieList = mCookieManager.getCookieStore().getCookies();
            checkCookie(mCookieList);
            e("MainUrl","HTTP 301 :"+mUrl);
            return;
        case HttpURLConnection.HTTP_FORBIDDEN:
            e("MainUrl","IP block or cookie err");
            return;
        case HttpURLConnection.HTTP_UNAVAILABLE:
            InputStream mInputStream = mCheckConn.getErrorStream();
            BufferedReader mBufferedReader = new BufferedReader(new InputStreamReader(mInputStream));
            StringBuilder sb = new StringBuilder();
            String str;
            while ((str = mBufferedReader.readLine()) != null){
                sb.append(str);
            }
            mInputStream.close();
            mBufferedReader.close();
            mCookieList = mCookieManager.getCookieStore().getCookies();
            str = sb.toString();
            getCheckAnswer(str);
            break;
        default:
            e("MainUrl","UnCatch Http code: "+mGetMainConn.getHeaderField("Location"));
            break;
    }
}
 
源代码20 项目: jsoup-learning   文件: HttpConnection.java
static Response execute(Connection.Request req, Response previousResponse) throws IOException {
    Validate.notNull(req, "Request must not be null");
    String protocol = req.url().getProtocol();
    if (!protocol.equals("http") && !protocol.equals("https"))
        throw new MalformedURLException("Only http & https protocols supported");

    // set up the request for execution
    if (req.method() == Connection.Method.GET && req.data().size() > 0)
        serialiseRequestUrl(req); // appends query string
    HttpURLConnection conn = createConnection(req);
    Response res;
    try {
        conn.connect();
        if (req.method() == Connection.Method.POST)
            writePost(req.data(), conn.getOutputStream());

        int status = conn.getResponseCode();
        boolean needsRedirect = false;
        if (status != HttpURLConnection.HTTP_OK) {
            if (status == HttpURLConnection.HTTP_MOVED_TEMP || status == HttpURLConnection.HTTP_MOVED_PERM || status == HttpURLConnection.HTTP_SEE_OTHER)
                needsRedirect = true;
            else if (!req.ignoreHttpErrors())
                throw new HttpStatusException("HTTP error fetching URL", status, req.url().toString());
        }
        res = new Response(previousResponse);
        res.setupFromConnection(conn, previousResponse);
        if (needsRedirect && req.followRedirects()) {
            req.method(Method.GET); // always redirect with a get. any data param from original req are dropped.
            req.data().clear();
            req.url(new URL(req.url(), res.header("Location")));
            for (Map.Entry<String, String> cookie : res.cookies.entrySet()) { // add response cookies to request (for e.g. login posts)
                req.cookie(cookie.getKey(), cookie.getValue());
            }
            return execute(req, res);
        }
        res.req = req;

        // check that we can handle the returned content type; if not, abort before fetching it
        String contentType = res.contentType();
        if (contentType != null && !req.ignoreContentType() && (!(contentType.startsWith("text/") || contentType.startsWith("application/xml") || contentType.startsWith("application/xhtml+xml"))))
            throw new UnsupportedMimeTypeException("Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml",
                    contentType, req.url().toString());

        InputStream bodyStream = null;
        InputStream dataStream = null;
        try {
            dataStream = conn.getErrorStream() != null ? conn.getErrorStream() : conn.getInputStream();
            bodyStream = res.hasHeader("Content-Encoding") && res.header("Content-Encoding").equalsIgnoreCase("gzip") ?
                    new BufferedInputStream(new GZIPInputStream(dataStream)) :
                    new BufferedInputStream(dataStream);

            res.byteData = DataUtil.readToByteBuffer(bodyStream, req.maxBodySize());
            res.charset = DataUtil.getCharsetFromContentType(res.contentType); // may be null, readInputStream deals with it
        } finally {
            if (bodyStream != null) bodyStream.close();
            if (dataStream != null) dataStream.close();
        }
    } finally {
        // per Java's documentation, this is not necessary, and precludes keepalives. However in practise,
        // connection errors will not be released quickly enough and can cause a too many open files error.
        conn.disconnect();
    }

    res.executed = true;
    return res;
}