GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
1
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
mark.george
/
httpcat
Browse code
Update README, and add binaries.
master
1 parent
952a3a1
commit
ae14ed9f0326a17cdead6b422ff8b639cc17df7f
Mark George
authored
on 13 Mar 2022
Patch
Showing
1 changed file
README.md
Ignore Space
Show notes
View
README.md
httpcat =============== A netcat like tool for analysing/mocking HTTP requests (from both server and client perspective). My first experiment with Go. ## Usage ``` httpcat [OPTIONS] <command> Application Options: -v, --verbose Show additional details --headers Show headers and request/status line only (default is everything) --bodies Show bodies only (default is everything) --nocolour Don't use colours (default is requests are blue and responses are red) --notimestamps Don't show timestamps Help Options: -h, --help Show this help message Available commands: client Send an HTTP request proxy Start a reverse HTTP logging proxy server Start a mock HTTP server version Display version ``` Get help about a specific command by adding `--help` after the command. Example: ``` httpcat client --help ``` ## Client Mode Sends a request to the specified server and displays the response. ### Usage ``` httpcat [OPTIONS] client [client-OPTIONS] Application Options: -v, --verbose Show additional details --headers Show headers and request/status line only (default is everything) --bodies Show bodies only (default is everything) --nocolour Don't use colours (default is requests are blue and responses are red) --notimestamps Don't show timestamps Help Options: -h, --help Show this help message [client command options] -u, --uri= The URI to send the request to --header= A header to add to request in the form name:value. Use multiple times for multiple headers. -m, --method= HTTP method for request (default: GET) -b, --body= Request body to send ``` ### Example ``` httpcat client --method POST --body TESTING --uri http://localhost:8080/api/testing ``` ## Server Mode Creates mock routes that listen on specific paths and return specific response bodies. Displays the details of any requests that it receives. ### Usage ``` httpcat [OPTIONS] server [server-OPTIONS] Application Options: -v, --verbose Show additional details --headers Show headers and request/status line only (default is everything) --bodies Show bodies only (default is everything) --nocolour Don't use colours (default is requests are blue and responses are red) --notimestamps Don't show timestamps Help Options: -h, --help Show this help message [server command options] -p, --port= Port to listen on. (default: 8080) -r, --route= Route which is made up of a path, a response body, and a response status, all separated by the pipe character. Repeat for additional routes. (default: /|testing|200) -c, --cors Enable Cross Origin Resource Sharing (CORS). -H, --header= A header to add to response in the form name:value. Repeat for additional headers. ``` ### Example ``` httpcat server --port 8080 --route "/hello|Hello World|200" --header "Content-Type:text/plain" ``` This creates a web server that listens on port 8080 and responds to any requests to the `/hello` path with the response `Hello World` and response code `200`. Repeat the `--route` option to add more routes. ## Proxy Mode Creates a reverse proxy that displays all HTTP requests and responses that pass through it. ### Usage ``` httpcat [OPTIONS] proxy [proxy-OPTIONS] Application Options: -v, --verbose Show additional details --headers Show headers and request/status line only (default is everything) --bodies Show bodies only (default is everything) --nocolour Don't use colours (default is requests are blue and responses are red) --notimestamps Don't show timestamps Help Options: -h, --help Show this help message [proxy command options] -p, --port= The port that the proxy listens on. -t, --target= ``` ### Example ``` httpcat proxy --port 8090 --target http://localhost:8080 ``` Any requests sent to port 8090 will be forwarded to `http://localhost:8080` and all requests and responses will be displayed. ## Building ``` cd src go build -o ../httpcat ``` ### Cross Compiling Linux ``` GOOS=linux GOARCH=amd64 go build -o ../httpcat-linux ``` Windows ``` GOOS=windows GOARCH=amd64 go build -o ../httpcat-win64 ``` Intel Mac ``` GOOS=darwin GOARCH=amd64 go build -o ../httpcat-mac-intel ``` M1/ARM64 Mac ``` GOOS=darwin GOARCH=arm64 go build -o ../httpcat-mac-arm64 ```
httpcat =============== A netcat like tool for analysing/mocking HTTP requests (from both server and client perspective). My first experiment with Go. ## Usage Usage: Client mode httpcat -client [options] http://uri-to-send-request-to.com Currently only supports GET requests. Server mode httpcat -server [options] Options (either mode) -entire or -e : Display entire request/response instead of just the body. -verbose or -v : Be verbose. Options (client mode only) -accept or -a [accept string] : Adds 'Accept' header to request. Options (server mode only) -body or -b [body message] : Body to respond with. Response code will default to 200. -port or -p [port] : Port to listen on. -response or -r [response code] : Status code to respond with. Defaults to 204. -cors or -c : Enable Cross Origin Resource Sharing support. -separator or -s [separator string] : Use the provided separator to separate messages. ## Building ``` cd src go build -o ../httpcat ``` ### Cross Compiling Linux ``` GOOS=linux GOARCH=amd64 go build -o ../httpcat-linux ``` Windows ``` GOOS=windows GOARCH=amd64 go build -o ../httpcat-win64 ``` Intel Mac ``` GOOS=darwin GOARCH=amd64 go build -o ../httpcat-mac-intel ``` M1/ARM64 Mac ``` GOOS=darwin GOARCH=arm64 go build -o ../httpcat-mac-arm64 ``` ## To Do Add support for DELETE, PUT, and POST requests in client mode.
Show line notes below