joyent/node-manta — pull request #161 by bahamas10 (2013-12-15 20:25:49+00:00)
Title: Add headers to mget, as well as an minfo (HEAD) tool

# summary

This adds `-H` to `mget`, to make it show headers sent with the file as well as the data. This mimics the behavior of `curl -i`.

Also, this adds an `minfo`, command, which works like the above command except it does `client.info` (`HEAD`), to make it mimic the behavior of `curl -I`

# example

### `mget`

Specify `-H` to print headers as well as the objects contents

```
$ ./mget ~~/stor/foo/a
hello
$ ./mget -H ~~/stor/foo/a
HTTP/1.1 200 OK
etag: a59d1083-55c2-c267-dae2-82dad3652859
last-modified: Sat, 14 Dec 2013 21:29:46 GMT
accept-ranges: bytes
content-type: application/octet-stream
content-md5: sZRqySSS0jR8YjW00mERhA==
content-length: 6
durability-level: 2
date: Sun, 15 Dec 2013 20:21:00 GMT
server: Manta
x-request-id: 859424cb-d53a-440c-8629-73d66e0288a1
x-response-time: 26
x-server-name: 39adec6c-bded-4a14-9d80-5a8bfc1121f9
connection: keep-alive

hello
```

Headers are written to stderr, so the data can still be piped

```
$ ./mget -H ~~/stor/foo/a > a
HTTP/1.1 200 OK
etag: a59d1083-55c2-c267-dae2-82dad3652859
last-modified: Sat, 14 Dec 2013 21:29:46 GMT
accept-ranges: bytes
content-type: application/octet-stream
content-md5: sZRqySSS0jR8YjW00mERhA==
content-length: 6
durability-level: 2
date: Sun, 15 Dec 2013 20:21:07 GMT
server: Manta
x-request-id: 4efd4f6f-bc31-4da2-bae8-e7d93e700c6f
x-response-time: 22
x-server-name: 02d02889-cd80-4ac1-bc0c-4775b86661e4
connection: keep-alive

~~/stor/foo/a [=====================================================================================================================>] 100% 6B
$ cat a
hello
```

### `minfo`

Like above, except no data is received

```
$ ./minfo ~~/stor/foo/a
HTTP/1.1 200 OK
etag: a59d1083-55c2-c267-dae2-82dad3652859
last-modified: Sat, 14 Dec 2013 21:29:46 GMT
content-md5: sZRqySSS0jR8YjW00mERhA==
durability-level: 2
content-length: 6
content-type: application/octet-stream
date: Sun, 15 Dec 2013 20:21:19 GMT
server: Manta
x-request-id: b64515f0-9e85-4fad-bc80-05445ae4d47e
x-response-time: 9
x-server-name: 7854e6a4-5c2e-4ed1-8551-f4e066ab817f
connection: keep-alive

```