https://github.com/somajitdey/httparse
Command-line parser for http request headers. Also see below link for related project.
https://github.com/somajitdey/httparse
bash command-line header-parser http http-header http-header-parser http-request http-server httparse httparser jq parse parser shell
Last synced: 6 months ago
JSON representation
Command-line parser for http request headers. Also see below link for related project.
- Host: GitHub
- URL: https://github.com/somajitdey/httparse
- Owner: SomajitDey
- License: gpl-3.0
- Created: 2021-04-29T14:50:50.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-30T09:19:40.000Z (over 4 years ago)
- Last Synced: 2024-10-12T12:18:59.866Z (12 months ago)
- Topics: bash, command-line, header-parser, http, http-header, http-header-parser, http-request, http-server, httparse, httparser, jq, parse, parser, shell
- Language: Shell
- Homepage: https://github.com/SomajitDey/sertain
- Size: 17.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httparse
Takes http request as input and outputs the headers and their values as json. Exits just before reading the request body. Doesn't parse query parameters from the path though. It's on the TODO list.
#### Dependency:
`bash`
(optional) `mktemp` and `jq`
#### Test-drive:
Run a simple http server in foreground in a terminal:
```bash
ncat \
-c './httparse >/dev/tty ;printf "HTTP/1.1 200 OK\r\n"; timeout 1 cat >/dev/tty' \
-kl 8080
```In another terminal:
```bash
curl localhost:8080 -d "Hello server"$'\r\n'
```See what you got in the first terminal :-)
Now, open http://localhost:8080 in a browser and check the new output at the first terminal.
#### A simple Bash-script server using `httparse`:
The demo-server provided, uses `httparse`. Shows any POST/PUT payload on the server terminal, and greets client on GET.
Run the server on port 8080 as:
```bash
ncat -e './demo-server' -kl 8080
```Open http://localhost:8080 in a browser.
Or, post a simple payload using cURL:
```bash
curl localhost:8080 -d "Hello server"
```