Codota Logo
HurlStack
Code IndexAdd Codota to your IDE (free)

How to use
HurlStack
in
com.android.volley.toolbox

Best Java code snippets using com.android.volley.toolbox.HurlStack (Showing top 20 results out of 315)

Refine searchRefine arrow

  • RequestQueue
  • Common ways to obtain HurlStack
private void myMethod () {
HurlStack h =
  • Codota Iconnew HurlStack()
  • Smart code suggestions by Codota
}
origin: chentao0707/SimplifyReader

/**
 * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it.
 *
 * @param context A {@link android.content.Context} to use for creating the cache dir.
 * @param stack An {@link HttpStack} to use for the network, or null for default.
 * @return A started {@link RequestQueue} instance.
 */
public static RequestQueue newRequestQueue(Context context, HttpStack stack) {
  File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR);
  String userAgent = "volley/0";
  try {
    String packageName = context.getPackageName();
    PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0);
    userAgent = packageName + "/" + info.versionCode;
  } catch (NameNotFoundException e) {
  }
  if (stack == null) {
    if (Build.VERSION.SDK_INT >= 9) {
      stack = new HurlStack();
    } else {
      // Prior to Gingerbread, HttpUrlConnection was unreliable.
      // See: http://android-developers.blogspot.com/2011/09/androids-http-clients.html
      stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent));
    }
  }
  Network network = new BasicNetwork(stack);
  RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network);
  queue.start();
  return queue;
}
origin: mcxiaoke/android-volley

HttpURLConnection connection = openConnection(parsedUrl, request);
for (String headerName : map.keySet()) {
  connection.addRequestProperty(headerName, map.get(headerName));
setConnectionParametersForRequest(connection, request);
    connection.getResponseCode(), connection.getResponseMessage());
BasicHttpResponse response = new BasicHttpResponse(responseStatus);
if (hasResponseBody(request.getMethod(), responseStatus.getStatusCode())) {
  response.setEntity(entityFromConnection(connection));
origin: chentao0707/SimplifyReader

/**
 * Opens an {@link java.net.HttpURLConnection} with parameters.
 * @param url
 * @return an open connection
 * @throws java.io.IOException
 */
private HttpURLConnection openConnection(URL url, Request<?> request) throws IOException {
  HttpURLConnection connection = createConnection(url);
  int timeoutMs = request.getTimeoutMs();
  connection.setConnectTimeout(timeoutMs);
  connection.setReadTimeout(timeoutMs);
  connection.setUseCaches(false);
  connection.setDoInput(true);
  // use caller-provided custom SslSocketFactory, if any, for HTTPS
  if ("https".equals(url.getProtocol()) && mSslSocketFactory != null) {
    ((HttpsURLConnection)connection).setSSLSocketFactory(mSslSocketFactory);
  }
  return connection;
}
origin: chentao0707/SimplifyReader

HttpURLConnection connection = openConnection(parsedUrl, request);
for (String headerName : map.keySet()) {
  connection.addRequestProperty(headerName, map.get(headerName));
setConnectionParametersForRequest(connection, request);
    connection.getResponseCode(), connection.getResponseMessage());
BasicHttpResponse response = new BasicHttpResponse(responseStatus);
response.setEntity(entityFromConnection(connection));
for (Entry<String, List<String>> header : connection.getHeaderFields().entrySet()) {
  if (header.getKey() != null) {
origin: stackoverflow.com

 RequestQueue mRequestQueue;

// Instantiate the cache
Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap

// Set up the network to use HttpURLConnection as the HTTP client.
Network network = new BasicNetwork(new HurlStack());

// Instantiate the RequestQueue with the cache and network.
mRequestQueue = new RequestQueue(cache, network);

// Start the queue
mRequestQueue.start();
origin: stackoverflow.com

HurlStack hurlStack = new HurlStack() {
  @Override
  protected HttpURLConnection createConnection(URL url) throws IOException {
requestQueue.add(jsonObjectRequest);
origin: stackoverflow.com

Network network = new BasicNetwork(new HurlStack());
mRequestQueue.start();
mRequestQueue.add(stringRequest);
origin: mcxiaoke/android-volley

@Test public void connectionForPatchRequest() throws Exception {
  TestRequest.Patch request = new TestRequest.Patch();
  assertEquals(request.getMethod(), Method.PATCH);
  HurlStack.setConnectionParametersForRequest(mMockConnection, request);
  assertEquals("PATCH", mMockConnection.getRequestMethod());
  assertFalse(mMockConnection.getDoOutput());
}
origin: stackoverflow.com

 RequestQueue requestQueue = Volley.newRequestQueue(context, new HurlStack() {
  @Override
  protected HttpURLConnection createConnection(URL url) throws IOException {
    HttpURLConnection connection = super.createConnection(url);
    connection.setInstanceFollowRedirects(false);

    return connection;
  }
});
origin: chentao0707/SimplifyReader

case Method.POST:
  connection.setRequestMethod("POST");
  addBodyIfExists(connection, request);
  break;
case Method.PUT:
  connection.setRequestMethod("PUT");
  addBodyIfExists(connection, request);
  break;
case Method.HEAD:
case Method.PATCH:
  connection.setRequestMethod("PATCH");
  addBodyIfExists(connection, request);
  break;
default:
origin: stackoverflow.com

 private static RequestQueue mRequestQueue;

 public RequestQueue getRequestQueue()
 {
  if (mRequestQueue == null) {
    Cache cache = new DiskBasedCache(MTXApplication.getAppContext().getCacheDir(), 20 * 1024 * 1024);
    Network network = new BasicNetwork(new HurlStack());
    mRequestQueue = new RequestQueue(cache, network);
    mRequestQueue.start();
  }
  return mRequestQueue;

}
origin: mcxiaoke/android-volley

@Test public void connectionForPostRequest() throws Exception {
  TestRequest.Post request = new TestRequest.Post();
  assertEquals(request.getMethod(), Method.POST);
  HurlStack.setConnectionParametersForRequest(mMockConnection, request);
  assertEquals("POST", mMockConnection.getRequestMethod());
  assertFalse(mMockConnection.getDoOutput());
}
origin: AnandChowdhary/saga-android

HttpURLConnection connection = openConnection(parsedUrl, request);
for (String headerName : map.keySet()) {
  connection.addRequestProperty(headerName, map.get(headerName));
setConnectionParametersForRequest(connection, request);
    connection.getResponseCode(), connection.getResponseMessage());
BasicHttpResponse response = new BasicHttpResponse(responseStatus);
response.setEntity(entityFromConnection(connection));
for (Entry<String, List<String>> header : connection.getHeaderFields().entrySet()) {
  if (header.getKey() != null) {
origin: stackoverflow.com

 private static Network getNetwork() {
  HttpStack stack;
  String userAgent = "volley/0";
  if(Build.VERSION.SDK_INT >= 9) {
    stack = new HurlStack();
  } else {
    stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent));
  }
  return new BasicNetwork(stack);
}
origin: mcxiaoke/android-volley

case Method.POST:
  connection.setRequestMethod("POST");
  addBodyIfExists(connection, request);
  break;
case Method.PUT:
  connection.setRequestMethod("PUT");
  addBodyIfExists(connection, request);
  break;
case Method.HEAD:
case Method.PATCH:
  connection.setRequestMethod("PATCH");
  addBodyIfExists(connection, request);
  break;
default:
origin: jiangqqlmj/FastDev4Android

/**
 * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it.
 *
 * @param context A {@link Context} to use for creating the cache dir.
 * @param stack An {@link HttpStack} to use for the network, or null for default.
 * @return A started {@link RequestQueue} instance.
 */
public static RequestQueue newRequestQueue(Context context, HttpStack stack) {
  File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR);
  String userAgent = "volley/0";
  try {
    String packageName = context.getPackageName();
    PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0);
    userAgent = packageName + "/" + info.versionCode;
  } catch (NameNotFoundException e) {
  }
  if (stack == null) {
    if (Build.VERSION.SDK_INT >= 9) {
      stack = new HurlStack();
    } else {
      // Prior to Gingerbread, HttpUrlConnection was unreliable.
      // See: http://android-developers.blogspot.com/2011/09/androids-http-clients.html
      stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent));
    }
  }
  Network network = new BasicNetwork(stack);
  RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network);
  queue.start();
  return queue;
}
origin: jiangqqlmj/FastDev4Android

HttpURLConnection connection = openConnection(parsedUrl, request);
for (String headerName : map.keySet()) {
  connection.addRequestProperty(headerName, map.get(headerName));
setConnectionParametersForRequest(connection, request);
    connection.getResponseCode(), connection.getResponseMessage());
BasicHttpResponse response = new BasicHttpResponse(responseStatus);
if (hasResponseBody(request.getMethod(), responseStatus.getStatusCode())) {
  response.setEntity(entityFromConnection(connection));
origin: stackoverflow.com

 RequestQueue volleyQueue = Volley.newRequestQueue(this);
DiskBasedCache cache = new DiskBasedCache(getCacheDir(), 16 * 1024 * 1024);
volleyQueue = new RequestQueue(cache, new BasicNetwork(new HurlStack()));
volleyQueue.start();
origin: mcxiaoke/android-volley

@Test public void connectionForDeprecatedPostRequest() throws Exception {
  TestRequest.DeprecatedPost request = new TestRequest.DeprecatedPost();
  assertEquals(request.getMethod(), Method.DEPRECATED_GET_OR_POST);
  HurlStack.setConnectionParametersForRequest(mMockConnection, request);
  assertEquals("POST", mMockConnection.getRequestMethod());
  assertTrue(mMockConnection.getDoOutput());
}
origin: xuningjack/AndroidNet

HttpURLConnection connection = openConnection(parsedUrl, request);
for (String headerName : map.keySet()) {
  connection.addRequestProperty(headerName, map.get(headerName));
setConnectionParametersForRequest(connection, request);
    connection.getResponseCode(), connection.getResponseMessage());
BasicHttpResponse response = new BasicHttpResponse(responseStatus);
response.setEntity(entityFromConnection(connection));
for (Entry<String, List<String>> header : connection.getHeaderFields().entrySet()) {
  if (header.getKey() != null) {
com.android.volley.toolboxHurlStack

Javadoc

An com.android.volley.toolbox.HttpStack based on java.net.HttpURLConnection.

Most used methods

  • <init>
  • setConnectionParametersForRequest
  • createConnection
    Create an HttpURLConnection for the specified url.
  • addBodyIfExists
  • entityFromConnection
    Initializes an HttpEntity from the given HttpURLConnection.
  • openConnection
    Opens an HttpURLConnection with parameters.
  • hasResponseBody
    Checks if a response message contains a body.
  • performRequest

Popular in Java

  • Start an intent from android
  • getSupportFragmentManager (FragmentActivity)
  • onRequestPermissionsResult (Fragment)
  • getSharedPreferences (Context)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JFileChooser (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now