Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lostsh/statuscode
get http status code using an HTTP request on port 80
https://github.com/lostsh/statuscode
c-sockets c99 http-code socket-programming
Last synced: 5 days ago
JSON representation
get http status code using an HTTP request on port 80
- Host: GitHub
- URL: https://github.com/lostsh/statuscode
- Owner: lostsh
- Created: 2024-04-02T12:01:48.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-05-16T09:31:42.000Z (5 months ago)
- Last Synced: 2024-09-25T21:19:12.822Z (8 days ago)
- Topics: c-sockets, c99, http-code, socket-programming
- Language: C
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# statuscode
Simple C99 script to retrieve **HTTP status code** from _(simple)_ request on port **80** of a given ip.
> Minimalist dependecy on sys lib
>> - main.c: `stdio.h`
>> - requestor.c: `unistd.h` _(for i/o)_, `sys/socket.h`, `arpa/inet.h`To be precise, the script is just sending `HEAD / HTTP1.0\r\n\r\n` to port **80** of the given target ip. Then read the first **16 bytes** of the response to extract the **http status code**.
For refence about the HTTP verb `HEAD` see [rfc spec](https://www.rfc-editor.org/rfc/rfc1945.html#section-8.2) which explain is the same as `GET` but the server only answer with headers.
## Build / Compile
### 1. Using make
Just type `make` into the directory containing the `Makefile` and the binary will be build into `bin/`.### 2. Using gcc
From the dicretory containing `src/` and `bin/` use the following gcc compilation line :
```bash
gcc -g -std=c99 -Wall -pedantic -D_XOPEN_SOURCE=700 -fsanitize=address src/main.c src/requestor.c -o bin/requestor
```## Install
## Run
The binary file is in the `bin/` direcotry, either `main` or `requestor`.Give target ip by argument. `./bin/requestor -t 1.1.1.1`.
Verbose option is available, to enable it add the `-v` argument to comand line.
## Example