<commit_before>//////////////////////////////////////////////////////////////////////////////////////////////////
//
//  HTTPTask.swift
//
//  Created by <NAME> on 6/3/14.
//  Copyright (c) 2014 Vluxe. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////////////////////////

import Foundation

/// HTTP Verbs.
///
/// - GET: For GET requests.
/// - POST: For POST requests.
/// - PUT: For PUT requests.
/// - HEAD: For HEAD requests.
/// - DELETE: For DELETE requests.
public enum HTTPMethod: String {
    case GET = "GET"
    case POST = "POST"
    case PUT = "PUT"
    case HEAD = "HEAD"
    case DELETE = "DELETE"
}

/// Object representation of a HTTP Response.
public class HTTPResponse {
    /// The header values in HTTP response.
    public var headers: Dictionary<String,String>?
    /// The mime type of the HTTP response.
    public var mimeType: String?
    /// The suggested filename for a downloaded file.
    public var suggestedFilename: String?
    /// The body or response data of the HTTP Response.
    public var responseObject: AnyObject?
    /// The status code of the HTTP Response.
    public var statusCode: Int?
    ///Returns the response as a string
    public func text() -> String? {
        var d = self.responseObject? as NSData
        var s = NSString(data: d, encoding: NSUTF8StringEncoding)
        return s
    }
}

/// Object representation of HTTP Basic Auth.
public struct HTTPAuth {
    /// Username for auth.
    public var username: String
    /// Password for auth.
    public var password: String
    /// Control for how long credentials should last. Default is ForSession.
    public var persistence: NSURLCredentialPersistence
    
    /**
        Initializes a new Auth Object.
    
        :param: username to provide for auth.
        :param: password to provide for auth.

    */
    public init(username: String, password: String) {
        self.username = username
        self.password = password
        self.persistence = .ForSession
    }<commit_msg>Use if-let to make it safer<commit_after>//////////////////////////////////////////////////////////////////////////////////////////////////
//
//  HTTPTask.swift
//
//  Created by <NAME> on 6/3/14.
//  Copyright (c) 2014 Vluxe. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////////////////////////

import Foundation

/// HTTP Verbs.
///
/// - GET: For GET requests.
/// - POST: For POST requests.
/// - PUT: For PUT requests.
/// - HEAD: For HEAD requests.
/// - DELETE: For DELETE requests.
public enum HTTPMethod: String {
    case GET = "GET"
    case POST = "POST"
    case PUT = "PUT"
    case HEAD = "HEAD"
    case DELETE = "DELETE"
}

/// Object representation of a HTTP Response.
public class HTTPResponse {
    /// The header values in HTTP response.
    public var headers: Dictionary<String,String>?
    /// The mime type of the HTTP response.
    public var mimeType: String?
    /// The suggested filename for a downloaded file.
    public var suggestedFilename: String?
    /// The body or response data of the HTTP Response.
    public var responseObject: AnyObject?
    /// The status code of the HTTP Response.
    public var statusCode: Int?
    ///Returns the response as a string
    public func text() -> String? {
        if let d = self.responseObject as? NSData {
            return  NSString(data: d, encoding: NSUTF8StringEncoding)
        }
        return nil
    }
}

/// Object representation of HTTP Basic Auth.
public struct HTTPAuth {
    /// Username for auth.
    public var username: String
    /// Password for auth.
    public var password: String
    /// Control for how long credentials should last. Default is ForSession.
    public var persistence: NSURLCredentialPersistence
    
    /**
        Initializes a new Auth Object.
    
        :param: username to provide for auth.
        :param: password to provide for auth.

    */
    public init(username: String, password: String) {
        self.username = username
        self.password = password
        self.persistence = .ForSession
    }
{'fraction_non_alphanumeric': 0.18405203565405925, 'fraction_numerical': 0.004336304504938569, 'mean_word_length': 1.6839043309631545, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '861808', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1034, 'n_words': 425}