Skip to content

slimane-swift/HTTPParser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTPParser

Swift Zewo Platform License Slack Travis Codebeat

HTTPParser is an HTTP (RFC 2616) parser for Swift 3.0.

Features

  • Asynchronous parsing
  • Handles persistent streams (keep-alive)
  • Decodes chunked encoding
  • Defends against buffer overflow attacks

HTTPParser wraps the C library http_parser used by node.js.

Usage

The parser works asynchronously so you should keep feeding it data that until it returns a request/response.

let parser = RequestParser()

while true {
    do {
        let data = getDataFromSomewhere()
        if let request = try parser.parse(data) {
            // do something with request
        }
    } catch {
        // something bad happened :(
        break
    }
}

Parser works the same way for requests and responses.

let parser = ResponseParser()

while true {
    do {
        let data = getDataFromSomewhere()
        if let response = try parser.parse(data) {
            // do something with response
        }
    } catch {
        // something bad happened :(
        break
    }
}

Installation

  • Add HTTPParser to your Package.swift
import PackageDescription

let package = Package(
	dependencies: [
		.Package(url: "https://github.com/Zewo/HTTPParser.git", majorVersion: 0, minor: 9),
	]
)

Support

If you need any help you can join our Slack and go to the #help channel. Or you can create a Github issue in our main repository. When stating your issue be sure to add enough details, specify what module is causing the problem and reproduction steps.

Community

Slack

The entire Zewo code base is licensed under MIT. By contributing to Zewo you are contributing to an open and engaged community of brilliant Swift programmers. Join us on Slack to get to know us!

License

This project is released under the MIT license. See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 100.0%