Code Monkey home page Code Monkey logo

httpdump's Introduction

httpdump

httpdump is a basic HTTP server dumping received requests content, which can be handy to debug HTTP clients requests. It doesn't do anything besides dumping the headers and content of HTTP requests it receives, and always returns 200 OK.

Note: this utility is currently in a very rudimentary form since it started as a quick'n dirty debugging tool, it may be improved in the future.

Build

To build httpdump from source, simply execute make at the root of the source tree, and if everything goes well the binary can be found in the current directory.

Usage

Usage: httpdump [OPTIONS]

Options:
   -bind  Address to bind on. If this value has a colon, as in ":8000" or
		"127.0.0.1:9001", it will be treated as a TCP address. If it
		begins with a "/" or a ".", it will be treated as a path to a
		UNIX socket. If it begins with the string "fd@", as in "fd@3",
		it will be treated as a file descriptor (useful for use with
		systemd, for instance). If it begins with the string "einhorn@",
		as in "einhorn@0", the corresponding einhorn socket will be
		used. If an option is not explicitly passed, the implementation
		will automatically select among "einhorn@0" (Einhorn), "fd@3"
		(systemd), and ":8000" (fallback) based on its environment.
   -h  display this help and exit
   -version  display version and exit

Given the following HTTP request using curl:

$ curl -X PUT -d key=value localhost:8000

httpdump outputs ([H]-prefixed lines are HTTP request headers, [B]-prefixed line is the HTTP request body if any):

2016/01/24 22:47:43.374892 [oxide.local/5c0JlaPI6B-000002] Started PUT "/" from [::1]:50034
[H] Content-Length: 9
[H] Content-Type: application/x-www-form-urlencoded
[H] User-Agent: curl/7.43.0
[H] Accept: */*
[B] key=value
2016/01/24 22:47:43.375022 [oxide.local/5c0JlaPI6B-000002] Returning 200 in 94.127µs

If the request Content-Type is "application/json" and the body is valid JSON data, httpdump will pretty-print it:

$ curl -X POST -H 'Content-Type: application/json' -d '{"key1":"value","key2":42,"key3":["a","b","c"]}' localhost:8000
2016/01/24 22:48:03.387585 [oxide.local/5c0JlaPI6B-000003] Started POST "/" from [::1]:50038
[H] User-Agent: curl/7.43.0
[H] Accept: */*
[H] Content-Type: application/json
[H] Content-Length: 15
[B] {
  "key1": "value",
  "key2": 42,
  "key3": [
    "a",
    "b",
    "c"
  ]
}
2016/01/24 22:48:03.387870 [oxide.local/5c0JlaPI6B-000003] Returning 200 in 248.491µs

License

httpdump is released under the MIT license, see the LICENSE file for details.

httpdump's People

Contributors

falzm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

sohamkamani

httpdump's Issues

Fail to make the project

[23:41:18]root@devstack:~/gsoc/httpdump# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:        14.04
Codename:       trusty

[23:41:44]root@devstack:~/gsoc/httpdump# go version
go version go1.4.2 linux/amd64

I install gb by go get github.com/constabulary/gb/...

I fail to make the project

[23:43:13]root@devstack:~/gsoc/httpdump# make
gb build -ldflags " \
                -X main.version=0.1.0 \
                -X main.buildDate='2016-03-06' \
                "
usage: 6l [options] main.6
  -1    use alternate profiling code
  -8    assume 64-bit addresses
  -B info
        define ELF NT_GNU_BUILD_ID note
  -C    check Go calls to C code
  -D addr
        data address
  -E sym
        entry symbol
  -I interp
        set ELF interp
  -L dir
        add dir to library path
  -H head
        header type
  -K    add stack underflow checks
  -O    print pc-line tables
  -Q    debug byte-register code gen
  -R rnd
        address rounding
  -S    check type signatures
  -T addr
        text address
  -V    print version and exit
  -W    disassemble input
  -X name value
        define string data
  -Z    clear stack frame on entry
  -a    disassemble output
  -c    dump call graph
  -d    disable dynamic executable
  -extld ld
        linker to run in external mode
  -extldflags ldflags
        flags for external linker
  -f    ignore version mismatch
  -g    disable go package data checks
  -installsuffix suffix
        pkg directory suffix
  -k sym
        set field tracking symbol
  -linkmode mode
        set link mode (internal, external, auto)
  -n    dump symbol table
  -o outfile
        set output file
  -r dir1:dir2:...
        set ELF dynamic linker search path
  -race
        enable race detector
  -s    disable symbol table
  -shared
        generate shared object (implies -linkmode external)
  -tmpdir dir
        leave temporary files in this directory
  -u    reject unsafe packages
  -v    print link trace
  -w    disable DWARF generation
# httpdump
httpdump
FATAL: command "build" failed: exit status 1
make: *** [httpdump] Error 1

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.