Giter Site home page Giter Site logo

akamemoe / dummyhttp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from svenstaro/dummyhttp

0.0 0.0 0.0 2.79 MB

Super simple HTTP server that replies a fixed body with a fixed response code

License: MIT License

Makefile 2.33% Rust 95.95% Shell 0.44% Dockerfile 1.28%

dummyhttp's Introduction

dummyhttp

GitHub Actions Workflow Docker Cloud Build Status AUR Crates.io license Lines of Code

A super simple HTTP server that replies with a fixed body and a fixed response code

This is a simple, small, self-contained, cross-platform CLI tool for debugging and testing. It allows you to return arbitrary HTTP responses and log incoming request data. HTTP/2 support included.

How to use

Log all incoming request data

dummyhttp --verbose
curl -X POST localhost:8080 -d hi
# ┌─Incoming request
# │ POST / HTTP/1.1
# │ Accept: */*
# │ Content-Length: 2
# │ Host: localhost:8080
# │ User-Agent: curl/7.66.0
# │ Content-Type: application/x-www-form-urlencoded
# │ Body:
# hi

Example with color:

Pretty log

Running with no arguments always returns 200 on all interfaces at port 8080

dummyhttp
curl localhost:8080
# < HTTP/1.1 200 OK
# < content-length: 10
# < date: Sat, 09 Jun 2018 13:56:14 GMT
# <
# dummyhttp

Always emit 400 Bad Request

dummyhttp -c 400
curl localhost:8080
# < HTTP/1.1 400 Bad Request
# < content-length: 10
# < date: Sat, 09 Jun 2018 13:57:53 GMT
# <
# dummyhttp

Always return a certain string

dummyhttp -b "Hello World"
curl localhost:8080
# < HTTP/1.1 200 OK
# < content-length: 12
# < date: Sat, 09 Jun 2018 13:58:57 GMT
# <
# Hello World

Return a specific header

dummyhttp -b "Hello World" -H application/json
curl localhost:8080
# < HTTP/1.1 200 OK
# < content-length: 10
# < content-type: application/json
# < date: Thu, 14 Jun 2018 11:10:14 GMT
# <
# Hello World

How to install

On Linux: Download dummyhttp-linux-amd64 from the releases page and run

chmod +x dummyhttp-linux-amd64
./dummyhttp-linux-amd64

On macOS: Download dummyhttp-macos-amd64 from the releases page and run

chmod +x dummyhttp-macos-amd64
./dummyhttp-macos-amd64

On Windows: Download dummyhttp-windows-amd64.exe from the releases page and run

dummyhttp-windows-amd64.exe

With Cargo: If you have a somewhat recent version of Rust and Cargo installed, you can run

cargo install dummyhttp
dummyhttp

Full options

dummyhttp 0.4.3
Sven-Hendrik Haase <[email protected]>
Super simple HTTP server that replies with a fixed body and a fixed response code

USAGE:
    dummyhttp [FLAGS] [OPTIONS]

FLAGS:
        --help       Prints help information
    -q, --quiet      Be quiet (log nothing)
    -V, --version    Prints version information
    -v, --verbose    Be verbose (log data of incoming and outgoing requests)

OPTIONS:
    -b, --body <body>                   HTTP body to send [default: dummyhttp]
    -c, --code <code>                   HTTP status code to send [default: 200]
    -h, --headers <headers>...          Headers to send (format: key:value)
    -i, --interfaces <interfaces>...    Interface to bind to [default: 0.0.0.0]
    -p, --port <port>                   Port on which to listen [default: 8080]
        --cert <tls-cert>               TLS cert to use
        --key <tls-key>                 TLS key to use

Releasing

This is mostly a note for me on how to release this thing:

  • Update version in Cargo.toml and README.md
  • git commit and git tag -s, git push
  • Run cargo publish
  • Releases will be built and deployed automatically by GitHub Actions
  • Update AUR package

dummyhttp's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar svenstaro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.