congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
HurlStack
Code IndexAdd Tabnine 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
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 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: 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 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: 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

  • Making http post requests using okhttp
  • addToBackStack (FragmentTransaction)
  • putExtra (Intent)
  • scheduleAtFixedRate (Timer)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now