Sample code for 30+ languages & platforms
Android™

Example: Http.HasRequestHeader method

Demonstrates the HasRequestHeader method.

Chilkat Android™ Downloads

Android™
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    CkHttp http = new CkHttp();

    http.SetRequestHeader("X-CSRF-Token","Fetch");

    boolean b = http.HasRequestHeader("X-CSRF-Token");
    if (b == true) {
        Log.i(TAG, "X-CSRF-Token: Yes");
        }
    else {
        Log.i(TAG, "X-CSRF-Token: No");
        }

    b = http.HasRequestHeader("X-Something");
    if (b == true) {
        Log.i(TAG, "X-Something: Yes");
        }
    else {
        Log.i(TAG, "X-Something: No");
        }

    //  The Accept and Accept-Encoding headers are default headers automatically added,
    //  unless the application chooses to remove by calling RemoveRequestHeader for each.
    b = http.HasRequestHeader("Accept");
    if (b == true) {
        Log.i(TAG, "Accept: Yes");
        }
    else {
        Log.i(TAG, "Accept: No");
        }

    //  Output:

    //  X-CSRF-Token: Yes
    //  X-Something: No
    //  Accept: Yes

  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}