HttpSession 1.3.8

HttpSession 1.3.8

Maintained by Keisuke Yamagishi.



  • By
  • keisuke

HttpSession

Overview

TCP / IP based HTTP communication can be simplified and Twitter OAuth

API Server: https://httpsession.work/

Recommended.

Codable SwiftyJSON and SWXMLHash is recommended.

Codable

SwiftyJSON

drmohundro/SWXMLHash

Twitter API callback fix

https://developer.twitter.com/en/docs/basics/callback_url.html

Installation

Cocoapods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate GMSDirection into your Xcode project using CocoaPods, specify it in your Podfile:

vi ./Podfile 

If you do not have the google map SDK for iOS

target 'Target Name' do
  use_frameworks!
  pod 'HttpSession'
end

Then, run the following command:

$ pod setup
$ pod install

Use it

Via SSH: For those who plan on regularly making direct commits, cloning over SSH may provide a better experience (which requires uploading SSH keys to GitHub):

$ git clone [email protected]:keisukeYamagishi/HttpSession.git

Via https: For those checking out sources as read-only, HTTPS works best:

$ git clone https://github.com/keisukeYamagishi/HttpSession.git

Sample code

GET http method

Http(url: "http://153.126.160.55/getApi.json", method: .get)
  .session(completion: { (data, responce, error) in
    self.detail(data: data!)
})

POST http method

let param = ["http_post":"Http Request POST 😄"]
            
Http(url: "http://153.126.160.55/postApi.json",method: .post)
  .session(param: param,
  completion: { (data, responce, error) in {
  self.detail(data: data!, param: param.hashString())
})

Download http method

Http(url: "https://shichimitoucarashi.com/mp4/file1.mp4", method: .get)
                .download(progress: { (written, total, expectedToWrite) in
                    let progress = Float(total) / Float(expectedToWrite)
                    print(String(format: "%.2f", progress * 100) + "%")                    
            }, download: { (location) in
                print ("location: \(String(describing: location))")
            }, completionHandler: { (data, responce, error) in
                self.detail(data: data!)
            })