Giter Club home page Giter Club logo

httparrot's Introduction

HTTParrot is http echo server which can be used when debugging, configure or testing your infrastructure. The utility is built on native Python3 classes and does not need any dependencies.

Usage

httparrot.py [-h] [--port PORT] [--address ADDRESS]
                    [--echo [TYPE [TYPE ...]]]
                    [--header [HEADER [HEADER ...]]]
                    [--body [BODY [BODY ...]]] [--status STATUS]
                    [--version {1.0,1.1,2}] [--time] [--silent]

Arguments:

  • port - server listen port, default 8000
  • address - server address, default localhost
  • echo - echo message types (list): headers - include request headers, body - include request body, query - include request line, client - include client connection, all - include all, none - no include
  • header - response headers (list)
  • body - echo response body
  • version - HTTP version, default 1.1
  • time - insert current time into echo response body
  • silent - enable silent mode
  • status - response code status

Examples

  • $ ./httparrot.py -p 8010 -v 1.0
$ curl -v localhost:8010/test?q=1

> GET /test?q=1 HTTP/1.1
> Host: localhost:8010
> User-Agent: curl/7.52.1
> Accept: */*
> 
# -v 1.0
< HTTP/1.0 200 OK	
< Server: BaseHTTP/0.6 Python/3.5.3
< Date: Thu, 28 Nov 2019 19:07:59 GMT
< Content-Type: text/html
< 
  • $ ./httparrot.py -p 8010 --body OK --echo headers --echo query --header "Connection: keep-alive" "Content-Type: text/html" --time
$ curl -v localhost:8010/test?q=1

> GET /test?q=1 HTTP/1.1
> Host: localhost:8010
> User-Agent: curl/7.52.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: BaseHTTP/0.6 Python/3.5.3
< Date: Thu, 28 Nov 2019 19:07:59 GMT
# --header "Connection: keep-alive"
< Connection: keep-alive
# --header "Content-Type: text/html"
< Content-Type: text/html 
< Content-Length: 96
< 

# --echo headers
Host: localhost:8010
User-Agent: curl/7.52.1
Accept: */*

# --echo query
GET /test?q=1 HTTP/1.1
# --time
1574968079
# --body OK
OK

  • $ ./httparrot.py -s 301 --header "Location: http://example.com"
$ curl -L -v localhost:8000/any-query --silent

> GET /any-query HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.52.1
> Accept: */*
> 
# -s 301
< HTTP/1.1 301 Moved Permanently
< Server: BaseHTTP/0.6 Python/3.5.3
< Date: Sat, 07 Dec 2019 08:35:03 GMT
# --header "Location: http://example.com"
< Location: http://example.com
< Content-Length: 1
< 
...
* Issue another request to this URL: 'http://example.com'
* Rebuilt URL to: http://example.com/
*   Trying 93.184.216.34...
* TCP_NODELAY set
* Connected to example.com (93.184.216.34) port 80 (#1)
> GET / HTTP/1.1
> Host: example.com
> User-Agent: curl/7.52.1
> Accept: */*
> 
< HTTP/1.1 200 OK
...

httparrot's People

Contributors

k1nky avatar

Watchers

 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.