Skip to content

A minimal, lightweight HTTP server. Designed for resource-constrained and embedded environments. [MIRROR ONLY]

Notifications You must be signed in to change notification settings

liuzhen9320/httpdx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

httpdx - Minimal HTTP Server

A minimal, lightweight HTTP server inspired by BusyBox httpd. Designed for resource-constrained and embedded environments.

Features

  • GET requests only: Full HTTP/1.1 support for GET method
  • Static file serving: Serves files from configurable document root
  • MIME type detection: Recognizes 25+ common file types
  • Logging: Access logging with timestamps (optional)
  • Directory listing: Optional directory index listing (similar to Apache/Nginx)
  • Small binary: ~75 KB stripped executable on Windows
  • Standard library only: No external dependencies, can be statically compiled
  • Cross-platform: Works on Linux, Windows (MinGW)

Building

Linux

# Default build
make

# With directory listing enabled
make ENABLE_DIR_LISTING=1

# With debug mode
make ENABLE_DEBUG_MODE=1

# With custom version
make VERSION="1.0.0"

Windows (MinGW)

# Default build
gcc -Wall -Wextra -Oz -ffunction-sections -fdata-sections -fomit-frame-pointer "-Wl,--gc-sections" -DENABLE_DIR_LISTING=1 httpd.c -o httpd.exe -lws2_32

# Using Makefile
make

Compile Flags

  • ENABLE_DIR_LISTING: Enable directory listing (0/1, default: 0)
  • ENABLE_DEBUG_MODE: Enable debug logging to stderr (0/1, default: 0)
  • ENABLE_FOOTER: Show "Powered by httpdx" footer in dir listing (0/1, default: 1)
  • VERSION: Version string displayed with -v flag (default: dev)

Usage

./httpd [options]

Options

  • -p PORT - Port to listen on (default: 8080)
  • -d ROOT - Document root directory (default: current directory)
  • -v - Show version
  • -h - Show help message

Examples

# Listen on port 8080, serve current directory
./httpd

# Listen on port 80, serve /var/www
./httpd -p 80 -d /var/www

MIME Types Supported

Text files:

  • HTML, plain text, CSS, CSV, XML

Scripting:

  • JavaScript (.js, .mjs), JSON

Fonts:

  • WOFF, WOFF2, TTF, OTF, EOT

Images:

  • PNG, JPEG, GIF, WebP, SVG, ICO

Media:

  • MP4, WebM, MP3, WAV

Archives:

  • ZIP, TAR, GZIP

Default: application/octet-stream for unknown types

Limitations

  • No HTTPS/TLS support
  • No configuration files (CLI only)
  • Sequential request handling (small concurrent connections)
  • HTTP/1.1 only
  • GET requests only
  • No CGI/scripting support

Portability

Tested on:

  • Linux (GCC)
  • Windows 10+ (MinGW GCC)

Should work on any platform with POSIX sockets or Windows Winsock2 API.

License

MIT - use freely in any project.

About

A minimal, lightweight HTTP server. Designed for resource-constrained and embedded environments. [MIRROR ONLY]

Topics

Resources

Stars

Watchers

Forks