htty, the HTTP TTY by htty (2024)

 s s .uef^" :8 :8 ..:d88E .88 .88 @L`888E :888ooo :888ooo 9888i .dL 888E .z8k -*8888888 -*8888888 `Y888k:*888. 888E~?888L 8888 8888 888E 888I 888E 888E 8888 8888 888E 888I 888E 888E 8888 8888 888E 888I 888E 888E .8888Lu= .8888Lu= 888E 888I 888E 888E ^%888* ^%888* x888N><888'm888N= 888> 'Y" 'Y" "88" 888 `Y" 888 __ .__ 88F J88" _/ |_| |__ ____ 98" @% \ __\ | \_/ __ \ ./" :" | | | Y \ ___/ ~` |__| |___| /\___ > __________\/_____\/____________________ / | \__ ___/\__ ___/\______ \ / ~ \| | | | | ___/ \ Y /| | | | | | \___|_ / |____| |____| |____| ______\/___________________.___. \__ ___/\__ ___/\__ | | | | | | / | | | | | | \____ | |____| |____| / ______| \/

htty is a console application for interacting with web servers. It’s a fun way to explore web APIs and to learn the ins and outs of HTTP.

htty, the HTTP TTY by htty (1) htty, the HTTP TTY by htty (2) htty, the HTTP TTY by htty (3)

htty, the HTTP TTY by htty (4) htty, the HTTP TTY by htty (5) htty, the HTTP TTY by htty (6)

See what’s changed lately by reading the project history.

It couldn’t be much easier.

$ gem install htty

You’ll need Ruby and RubyGems. It’s known to work well under OS X against Ruby v1.8.7, v1.9.2, v1.9.3, v2.0, v2.1, and v2.2.

  • Intuitive, Tab-completed commands and command aliases
  • Support for familiar HTTP methods GET, POST, PUT, and DELETE, as well as PATCH, HEAD, OPTIONS and TRACE
  • Support for HTTP Secure connections and HTTP Basic Authentication
  • Automatic URL-encoding of userinfo, paths, query-string parameters, and page fragments
  • Transcripts, both verbose and summary
  • Scripting via stdin
  • Dead-simple cookie handling and redirect following
  • Built-in help

The things you can do with htty are:

  • Build a request — you can tweak the address, headers, cookies, and body at will
  • Send the request to the server — after the request is sent, it remains unchanged in your session history
  • Inspect the server’s response — you can look at the status, headers, cookies, and body in various ways
  • Review history — a normal and a verbose transcript of your session are available at all times (destroyed when you quit htty)
  • Reuse previous requests — you can refer to prior requests and copy them

Here are a few annotated htty session transcripts to get you started (terminal screenshots shown here are also available in textual form).

Querying a web service

This simple example shows how to explore a read-only web service with htty.

htty, the HTTP TTY by htty (7)

You can point htty at a complete or partial web URL. If you don’t supply a URL, http://0.0.0.0/ (port 80) will be used. You can vary the protocol scheme, userinfo, host, port, path, query string, and fragment as you wish.

The htty shell prompt shows the address of the current request.

The get command is one of seven HTTP request methods supported. A concise summary of the response is shown when you issue a request.

You can follow redirects using the follow command. No request is made until you type a request command such as get or post.

htty, the HTTP TTY by htty (8)

You can tweak segments of the address at will. Here we are navigating the site’s path hierarchy, which you can do with relative as well as absolute pathspecs.

htty, the HTTP TTY by htty (9)

Here we add query-string parameters. Notice that characters that require URL encoding are automatically URL-encoded (unless they are part of a URL-encoded expression).

The headers-response and body-response commands reveal the details of a response.

htty, the HTTP TTY by htty (10)

There was some cruft in the web service’s response (a horizontal line, a passage reference, verse numbers, a copyright stamp, and line breaks). We eliminate it by using API options provided by the web service we’re talking to.

We do a Julia Child maneuver and use the address command to change the entire URL, rather than add individual query-string parameters one by one.

Exit your session at any time by typing quit or hitting Ctrl-D.

Working with cookies

The next example demonstrates htty’s HTTP Secure support and cookies features, as well as how to review and revisit past requests.

htty, the HTTP TTY by htty (11)

The https:// scheme and port 443 imply each other, just as the http:// scheme and port 80 imply each other. If you omit the scheme or the port, it will default to the appropriate value.

Notice that when cookies are offered in a response, a bold asterisk (it looks like a cookie) appears in the response summary. The same cookie symbol appears next to the Set-Cookie header when you display response headers.

htty, the HTTP TTY by htty (12)

The cookies-use command copies cookies out of the response into the next request. The cookie symbol appears next to the Cookie header when you display request headers.

htty, the HTTP TTY by htty (13)

An abbreviated history is available through the history command. Information about requests in the history includes request method, URL, number of headers (and a cookie symbol, if cookies were sent), and the size of the body. Information about responses in the history includes response code, number of headers (and a cookie symbol, if cookies were received), and the size of the body.

Note that history contains only numbered HTTP request and response pairs, not a record of all the commands you enter.

The reuse command makes a copy of the headers and body of an earlier request for you to build on.

Understanding complex HTTP conversations at a glance using history

Now we’ll look at htty’s HTTP Basic Authentication support and learn how to display unabbreviated transcripts of htty sessions.

Assume that we have the following Sinatra application listening on Sinatra’s default port, 4567.

require 'sinatra'get '/all-good' do [200, [['Set-Cookie', 'foo=bar; baz']], 'Hello World!']endput '/huh' do [404, 'What?']enddelete '/hurl' do [500, 'Barf!']endpost '/submit-novel' do redirect '/all-good'end

This application expects GET and POST requests and responds in various contrived ways.

htty, the HTTP TTY by htty (14)

When you change the userinfo portion of the address, or the entire address, the appropriate HTTP Basic Authentication header is created for you automatically. Notice that characters that require URL encoding are automatically URL-encoded (unless they are part of a URL-encoded expression).

When userinfo is supplied in a request, a bold mercantile symbol ( @ ) appears next to the resulting Authorization header when you display request headers (see below).

Type body-set to enter body data, and terminate it by entering two consecutive blank lines, or by hitting Ctrl-D. The body will only be sent for POST and PUT requests. The appropriate Content-Length header is created for you automatically (see below).

Different response codes are rendered with colors that suggest their meaning:

  • Response codes between 200 and 299 appear black on green to indicate success
  • Response codes between 300 and 399 appear white on blue to indicate redirection
  • Response codes between 400 and 499 appear white on red to indicate failure
  • Response codes between 500 and 599 appear flashing black on yellow to indicate a server error

htty, the HTTP TTY by htty (15)

As with the abbreviated history demonstrated earlier, verbose history shows a numbered list of requests and the responses they elicited. All information exchanged between client and server is shown.

Getting help

You can learn how to use htty commands from within htty.

htty, the HTTP TTY by htty (16)

The help command takes an optional argument of the abbreviated or full name of a command.

Report defects and feature requests on GitHub Issues.

Your patches are welcome, and you will receive attribution here for good stuff. Fork the official htty repository and send a pull request.

Development

After cloning the repository, bin/setup to install dependencies. Then rake to run the tests. You can also bin/console to get an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, bundle exec rake install. To release a new version, update the version number in lib/htty/version.rb, and then bundle exec rake release, which will create a Git tag for the version, push Git commits and tags, and push the .gem file to RubyGems.org.

Stay in touch with the htty project by following @get_htty on Twitter.

You can also get help in the #htty channel on Freenode.

The author, Nils Jonsson, owes a debt of inspiration to the http-console project.

Thanks to contributors (in alphabetical order):

Released under the MIT License.

htty, the HTTP TTY by htty (2024)

FAQs

What is the use of TTY? ›

TTY (Teletypewriter) is a device that allows users to send typed messages across phone lines. Many people who are Deaf, deafened, hard of hearing, or who are deafblind may use TTYs to call other individuals.

What is tty in shell? ›

The tty command of the terminal basically prints the file name of the terminal connected to standard input. tty is short for teletype, but popularly known as a terminal it allows you to interact with the system by passing on the data (your input) to the system and displaying the output produced by the system.

How do I use TTY on my phone? ›

Enable TTY on an iOS or Android device:
  1. Open 'Settings'
  2. Navigate to 'Accessibility'
  3. Tap 'TTY' or 'RTT/TTY' to enable the feature.
  4. You will now see an option to switch to TTY mode during a phone call.
Jun 1, 2024

How do I access TTY services? ›

More than 100 years after the invention of the telephone, deaf and hard of hearing people could finally make a telephone call to anyone. Today, TTY relay services, the original and now “traditional” relay service, can be reached by anyone by dialing 711 from a telephone or TTY.

What does TTY mean at the end of a phone number? ›

Teletypewriters (TTY), Telecommunications Device for the Deaf (TDD) and Text Telephones (TT) are special telecommunications equipment used by people who cannot use a regular telephone due to hearing loss or speech impairment.

What happens when TTY mode is on? ›

Text telephone (TTY) mode is used to send text over a telephone line. A TTY device must be connected to the computer to interpret the modified audio otherwise you might experience poor audio quality. Using TTY mode in a conference call may also cause audio quality issues. TTY mode is turned off by default.

Why do people still use TTY? ›

Deaf people use TTYs, a device that allows them to type their messages instead of speaking. Some businesses sometimes have TTYs and they advertise their separate TTY number for deaf people to use.

Should TTY be on or off? ›

Text telephone (TTY) mode is used to send text over a telephone line. A TTY device must be connected to the computer to interpret the modified audio otherwise you might experience poor audio quality. Using TTY mode in a conference call may also cause audio quality issues. TTY mode is turned off by default.

What is the benefit of TTY mode? ›

TTY machines allow users to continuously communicate as part of one conversation, without receiving constant message notifications and updates like from text messages. During a TTY conversation, the messages appear immediately on the other party's TTY screen without interruption.

How do I call someone with TTY? ›

Using the Telecommunications Relay Service - 711

With TRS, an operator types whatever you say so that the person you are calling can read your words on his or her TTY display. He or she will type back a response, which the TRS operator will read aloud for you to hear over the phone.

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Domingo Moore

Last Updated:

Views: 5973

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Domingo Moore

Birthday: 1997-05-20

Address: 6485 Kohler Route, Antonioton, VT 77375-0299

Phone: +3213869077934

Job: Sales Analyst

Hobby: Kayaking, Roller skating, Cabaret, Rugby, Homebrewing, Creative writing, amateur radio

Introduction: My name is Domingo Moore, I am a attractive, gorgeous, funny, jolly, spotless, nice, fantastic person who loves writing and wants to share my knowledge and understanding with you.