-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from termermc/master
Reformat for modern nimble project structure; include picohttpparser as submodule
- Loading branch information
Showing
7 changed files
with
66 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "vendor/picohttpparser"] | ||
path = vendor/picohttpparser | ||
url = https://github.com/h2o/picohttpparser.git | ||
url = https://github.com/h2o/picohttpparser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,22 @@ | ||
# nim-picohttpparser | ||
Nim binding for [picohttpparser](https://github.com/h2o/picohttpparser). | ||
|
||
##Setup | ||
In order to use these bindings in your program, you must install the | ||
[picohttpparser.h](https://github.com/h2o/picohttpparser/blob/master/picohttpparser.h) | ||
header on your machine, and link your Nim program with | ||
[picohttpparser.c](https://github.com/h2o/picohttpparser/blob/master/picohttpparser.c). | ||
## Setup | ||
Install `picohttpparser` with Nimble and you're ready to go. | ||
|
||
The easiest way to do this is to: | ||
|
||
1. Copy the [picohttpparser](https://github.com/h2o/picohttpparser) sources into your | ||
project sources, | ||
2. Use the [cincludes](http://nim-lang.org/docs/nimc.html) Nim compiler flag | ||
to add the picohttpparser sources to the C compiler include search path, | ||
3. And create a Nim file that uses the | ||
[compile pragma](http://nim-lang.org/docs/manual.html#implementation-specific-pragmas-compile-pragma) | ||
to compile | ||
[picohttpparser.c](https://github.com/h2o/picohttpparser/blob/master/picohttpparser.c). | ||
|
||
##Usage | ||
To use the low level picohttpparser API binding, `import picohttpparser_api` | ||
## Usage | ||
To use the low level picohttpparser API binding, `import picohttpparser/api` | ||
in your program, and use `parseRequest` or `tryParseRequest`. | ||
|
||
Converter `proc`s `toStringTableRef` and `toHttpHeaders` are provided to | ||
convert picohttpparser's native `seq[phr_header]` header type to types that | ||
are often used in Nim libraries. | ||
|
||
##Todo | ||
## TODO | ||
A high level picohttpparser API named `picohttpparser` would be nice. Patches | ||
welcome! | ||
|
||
##License | ||
## License | ||
This project is licensed under the same license as | ||
[picohttpparser](https://github.com/h2o/picohttpparser), which is | ||
dual-licensed under the Perl License or the MIT License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import picohttpparser/api | ||
export api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
[Package] | ||
# Package | ||
|
||
version = "0.10.0" | ||
version = "0.11.0" | ||
author = "Philip Wernersbach" | ||
description = "Bindings for picohttpparser." | ||
description = "Bindings for picohttpparser" | ||
license = "MIT" | ||
|
||
installDirs = @["vendor"] | ||
|
||
# Dependencies | ||
|
||
requires "nim >= 1.6.12" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import std/unittest | ||
|
||
import ../picohttpparser/api | ||
|
||
suite "Can parse simple request": | ||
var httpMethod: string | ||
var path: string | ||
var minorVersion: cint | ||
var headers: seq[phr_header] | ||
|
||
parseRequest("GET /test HTTP/1.1\r\n\r\n", httpMethod, path, minorVersion, headers) | ||
|
||
assert(path == "/test") |
Submodule picohttpparser
added at
066d2b