<commit_before>/*
 * Copyright (c) 2014. <NAME>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.yelinaung.android.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by <NAME> on 14/01/20.
 */
public class NetUtils {
    // Check the device is connected to the internet
    public static boolean isOnlineOrNot(Context c) {
        NetworkInfo netInfo = null;
        try {
            ConnectivityManager cm = (ConnectivityManager) c
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            netInfo = cm.getActiveNetworkInfo();
        } catch (SecurityException e) {
            e.printStackTrace();
        }
        return netInfo != null && netInfo.isConnectedOrConnecting();
    }


    public static void getStatus(String weburl, String ways)
    {
        try{
            List<String> httpWays= new ArrayList<String>();
            httpWays.add(ways.toUpperCase());
            httpWays.add(weburl);
            new checkWebStatus().execute(httpWays);
        }catch (NullPointerException ne){
            ne.printStackTrace();
        }

    }

    //Check the website http response code no
   private static class checkWebStatus extends AsyncTask<List<String>,Void,String>
    {

        @Override
        protected String doInBackground(List<String >...weburl) {
            Integer httpResponse = 0;
            HttpClient client = new DefaultHttpClient();
            HttpResponse response = null;

            try {
            if(weburl[0].get(0).toString().equals("POST")){
                HttpPost httptype = new HttpPost(weburl[0].get(1).toString());
                try {
                    response = client.execute(httptype);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }else if(weburl[0].get(0).toString().equals("GET")){
                HttpGet httptype = new HttpGet(weburl[0].get(1).toString());
                try {
                    response = client.execute(httptype);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }else if(weburl[0].get(0).toString().equals("PUT")){
                HttpPut httptype = new HttpPut(weburl[0].get(1).toString());
                try {
                    response = client.execute(httptype);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }else {
                HttpDelete httptype = new HttpDelete(weburl[0].get(1).toString());
                try {
                    response = client.execute(httptype);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

                httpResponse = response.getStatusLine().getStatusCode();

            }catch (SecurityException se){
                se.printStackTrace();
            }
            return httpResponse.toString();
        }
    }
}<commit_msg>Update checkWebstatus for all http method<commit_after>/*
 * Copyright (c) 2014. <NAME>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.yelinaung.android.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by <NAME> on 14/01/20.
 */
public class NetUtils {
    // Check the device is connected to the internet
    public static boolean isOnlineOrNot(Context c) {
        NetworkInfo netInfo = null;
        try {
            ConnectivityManager cm = (ConnectivityManager) c
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            netInfo = cm.getActiveNetworkInfo();
        } catch (SecurityException e) {
            e.printStackTrace();
        }
        return netInfo != null && netInfo.isConnectedOrConnecting();
    }


    public static void getStatus(String weburl, String ways)
    {
        try{
            List<String> httpWays= new ArrayList<String>();
            httpWays.add(ways.toUpperCase());
            httpWays.add(weburl);
            new checkWebStatus().execute(httpWays);
        }catch (NullPointerException ne){
            ne.printStackTrace();
        }

    }

    //Check the website http response code no
   private static class checkWebStatus extends AsyncTask<List<String>,Void,String>
    {

        @Override
        protected String doInBackground(List<String >...weburl) {
            Integer httpResponse = 0;
            HttpClient client = new DefaultHttpClient();
            HttpResponse response = null;

            try {
                if(weburl[0].get(0).toString().equals("POST")){
                HttpPost httptype = new HttpPost(weburl[0].get(1).toString());
                try {
                    response = client.execute(httptype);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }else if(weburl[0].get(0).toString().equals("GET")){
                HttpGet httptype = new HttpGet(weburl[0].get(1).toString());
                try {
                    response = client.execute(httptype);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }else if(weburl[0].get(0).toString().equals("PUT")){
                HttpPut httptype = new HttpPut(weburl[0].get(1).toString());
                try {
                    response = client.execute(httptype);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }else {
                HttpDelete httptype = new HttpDelete(weburl[0].get(1).toString());
                try {
                    response = client.execute(httptype);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
                httpResponse = response.getStatusLine().getStatusCode();
            }catch (SecurityException se){
                se.printStackTrace();
            }
            return httpResponse.toString();
        }
    }
}
{'fraction_non_alphanumeric': 0.10336239103362391, 'fraction_numerical': 0.007222914072229141, 'mean_word_length': 2.037443267776097, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2547', 'n_tokens_mistral': 2111, 'n_tokens_neox': 2028, 'n_words': 525}