Compare commits

..

9 Commits

Author SHA1 Message Date
cf2c07899c chore: add readme
All checks were successful
Test / test (push) Successful in 2m11s
2026-02-15 20:54:41 +01:00
5be98f04c1 wip
All checks were successful
Test / test (push) Successful in 2m9s
2026-02-15 20:48:09 +01:00
38c65df769 wip
Some checks failed
Test / test (push) Failing after 26s
2026-02-15 20:42:43 +01:00
e12b1ffe3e wip
Some checks failed
Test / test (push) Failing after 1s
2026-02-15 20:40:16 +01:00
93b1dfef79 wip
Some checks failed
Test / test (push) Failing after 8s
2026-02-15 20:38:14 +01:00
8c32b74838 wip
Some checks failed
Test / test (push) Has been cancelled
2026-02-15 20:37:57 +01:00
437a285cc8 wip
Some checks failed
Test / test (push) Failing after 15s
2026-02-15 20:19:38 +01:00
19fd94a675 wip
Some checks failed
Test / test (push) Has been cancelled
2026-02-15 20:18:40 +01:00
42a613279d chore: change runner
Some checks failed
Test / test (push) Failing after 27s
2026-02-15 20:16:56 +01:00
2 changed files with 52 additions and 6 deletions

View File

@@ -8,13 +8,12 @@ on:
jobs:
test:
runs-on: ubuntu-latest
runs-on: x86_64
container: golang:1.26
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Checkout
run: |
git clone --depth=1 --branch="${GITHUB_REF_NAME}" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" .
- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...

47
README.md Normal file
View File

@@ -0,0 +1,47 @@
# go-http-server
A minimal TCP-based HTTP server in Go for learning and experimentation. It demonstrates manual request-line and header parsing and simple connection handling.
Requires
- Go 1.26 or newer.
Quick start
1. Build
- cd into the project root (the directory that contains `go-http-server`) and run:
```
cd go-http-server
go build -o go-http-server
```
2. Run
- Start the server:
```
./go-http-server
```
- Or during development:
```
go run .
```
Testing
- Run unit tests:
```
cd go-http-server
go test ./...
```
Whats in the repo
- `main.go` — listener and connection lifecycle.
- `readheaders.go` — `readHeaders` and `parseRequestLine` logic; returns a `Headers` struct.
- `response_helper` — helpers for writing responses.
- `config` — runtime configuration (listen address, profiling toggle).
Notes
- The parser expects a request-line with exactly three tokens: `METHOD URI PROTO`.
- Header lines without a colon are ignored; values are trimmed.
- The server supports simple keep-alive behavior when the `Connection: keep-alive` header is present.
Contributing
- Open issues or PRs. Add tests for parsing or new behavior and run `go test ./...` before submitting.
License
- MIT