REBOL [
    Title: "HTTP Console"
    Purpose: "HTTP TTY-style Console"
    Date:  8-Sep-2010
    File: %httpc.r
    Version: 0.1.0
    Author: "Christopher Ross-Gill"
]

do http://www.ross-gill.com/r/rest
do http://www.ross-gill.com/r/altwebform

use [
    command request response
    root path query
    send commands
][
    root: http://www.rebol.com/
    path: "/"

    request: context [
        action: content: type: headers: none
    ]

    send: func [spec][
        spec: read/custom head change root/:path "rest" third spec
        set request none
        print rejoin [
            "[ " spec/status " ] " length? spec/http-headers " Headers"
        ]
        spec
    ]

    commands: use [args][[
          "address " args: "http://" to end (root: to-url args)
        | "cd " copy path to end
        | "get" (
            request/action: "get"
            response: send request
        )
        | "body" (
            print copy/part response/content 100
        )
    ]]

    while [not find ["q" "quit"] command: ask rejoin [root/:path "> "]][
        parse/all trim/head/tail command commands
        do []
    ]
]