Commit Graph

392 Commits

Author SHA1 Message Date
Juan Batiz-Benet
978c9fa16f cmds/add: use dagutils.Editor, like patch
This changes the pin behavior. It uses the filenames given through
the api, and allows files to be streamed faltly (not a hierarchy),
which is easier for other things (like vinyl in node-ipfs-api land).
Files can also be entirely out of order, and the garbage intermediate
directories will not be pinned (gc-ed later).

The changes also mean the output of add has changed slightly-- it
no longer shows the local path added, but rather the dag path
relative to the added roots. This is a small difference, but changes
tests.

The dagutils.Editor creates a lot of chaff (intermediate objects)
along the way. Wonder how we might minimize the writes to the
datastore...

This commit also removes the "NilRepo()" part of the --only-hash
mode. We need to store at least in an in-mem repo/datastore because
otherwise the dagutils.Editor breaks.

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
2015-08-12 08:24:06 +02:00
Juan Batiz-Benet
3ee83a7c5e fix cors: defaults should take the port of the listener
need to do it this way to avoid VERY confusing situations where
the user would change the API port (to another port, or maybe even
to :0). this way things dont break on the user, and by default,
users only need to change the API address and things should still
"just work"

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
2015-08-02 08:16:51 +02:00
Juan Benet
8a75c755d4 Merge pull request #1539 from ipfs/log-api-route
fix log tail command
2015-07-29 15:22:49 -07:00
Jeromy
082c147bbe should fix issue where 'read on closed body' error was leaking down
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-29 13:26:39 -07:00
Jeromy
b10e26a429 cancel contexts when client disconnects
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-29 11:02:10 -07:00
Juan Batiz-Benet
4a7c1cf802 add -w improvement: wrap multiple files in one dir
> ipfs add a b c
  added Qmbvkmk9LFsGneteXk3G7YLqtLVME566ho6ibaQZZVHaC9 a
  added QmR9pC5uCF3UExca8RSrCVL8eKv7nHMpATzbEQkAHpXmVM b
  added QmetGxZTgo8tYAKQH1KLsY13MxqeVHbxYVmvzBzJAKU6Z7 c
  added QmXg3WHLcjnz4ejeYF6FKVBkb4m1oKjQmF5fEWL9M1uQF3

  > ipfs ls QmXg3WHLcjnz4ejeYF6FKVBkb4m1oKjQmF5fEWL9M1uQF3
  Qmbvkmk9LFsGneteXk3G7YLqtLVME566ho6ibaQZZVHaC9 10 a
  QmR9pC5uCF3UExca8RSrCVL8eKv7nHMpATzbEQkAHpXmVM 10 b
  QmetGxZTgo8tYAKQH1KLsY13MxqeVHbxYVmvzBzJAKU6Z7 10 c

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
2015-07-29 03:07:39 -07:00
Juan Batiz-Benet
8f35c3bcd9 more serious CORS tests.
this commit introduces more serious CORS tests that check
status response codes, and run real HTTP requests.

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
2015-07-28 23:08:11 -07:00
Juan Batiz-Benet
d5f94be474 fix API handler to respect referer + exit on CORS
this commit makes the API handler short circuit the request if the
CORS headers say its not allowed. (the CORS handler only sets the
headers, but does not short-circuit)

It also makes the handler respect the referer again. See security
discussion at https://github.com/ipfs/go-ipfs/issues/1532

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
2015-07-28 23:08:11 -07:00
Juan Batiz-Benet
5d9ee59908 address CR comment re interface in cmds http handler
https://github.com/ipfs/go-ipfs/pull/1529#discussion_r35662230

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
2015-07-28 23:08:10 -07:00
Juan Batiz-Benet
4a571b099b implement arbitrary HTTP header support
this commit adds the ability to specify arbitrary HTTP headers
for either the Gateway or the API. simply set the desired headers
on the config:

    ipfs config --json API.HTTPHeaders.X-MyHdr '["meow :)"]'
    ipfs config --json Gateway.HTTPHeaders.X-MyHdr '["meow :)"]'

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
2015-07-28 23:08:10 -07:00
Juan Batiz-Benet
c633e2b575 cmds/http: remove referrer check
it used to be here for a CSRF check. but we now have CORS checks.

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
2015-07-28 23:08:09 -07:00
Juan Batiz-Benet
7cf5e87cfe Added API + Gateway support for arbitrary HTTP headers
This commit fixes + improves CORS support

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
2015-07-28 23:08:09 -07:00
Juan Benet
681da0aa21 Merge pull request #1531 from ipfs/fix/stream-header
only set stream header on streamed output
2015-07-28 12:59:54 -07:00
Jeromy Johnson
98559d0e0b put comment back 2015-07-28 08:44:35 -07:00
Shaun Bruce
c175700dea Better error message on unrecognized command
Closes issue #1436

License: MIT
Signed-off-by: Shaun Bruce <shaun.m.bruce@gmail.com>
2015-07-28 09:20:53 -06:00
Jeromy
2cad99d5ef only set stream header on streamed output
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-28 08:18:31 -07:00
Jeromy
8176766d5a naming and cleanup
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-27 17:25:38 -07:00
Jeromy
0c4b10afb2 comment need for custom client
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-27 15:19:43 -07:00
Jeromy
23d41e0823 address comments from CR and fix random failures
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-27 09:30:52 -07:00
Jeromy
1ce310be8b some commenting
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-26 11:28:53 -07:00
Jeromy
fd75b64630 refactor http client code
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-25 19:56:45 -07:00
Jeromy
2b06ffaa7d better refactor of http handler code
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-25 18:46:44 -07:00
Jeromy
a7e50f1fbc implement http trailers for errors after headers are sent
refactor http handler and copyChunks to get this all to work correctly
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-25 11:07:31 -07:00
Juan Batiz-Benet
814f437fb4 cmds/http/handler: set stream error trailer
stream output might break. in these cases we need to notify the
client. this is after a 200 response has been sent. We do this
by setting a special trailer (header after the body):

  X-Stream-Error: <error cause>

This is similar to what's done by systems like gRPC. This still
needs to be read + handled on the other side.

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
2015-07-24 14:49:34 -07:00
Juan Batiz-Benet
886d47561a http/client: log errors when stream copy fails
License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
2015-07-24 14:41:57 -07:00
Jeromy
8286abaf8c attempt at properly closing http response bodies
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-22 13:31:33 -07:00
Jeromy
5873aa2aaa if no context set in request, use context.TODO()
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-20 21:46:51 -07:00
Jeromy
bb3a75aa08 remove context from context
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-20 20:53:06 -07:00
Jeromy
f9f3c6a527 make offline commands respect timeout
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-20 14:34:16 -07:00
Jeromy
6083007987 add a global timeout flag for to be setting timeouts
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2015-07-20 12:53:37 -07:00
gatesvp
e55a130b49 Add hidden file support to add
License: MIT
Signed-off-by: Gaetan Voyer-Perrault <gatesvp@gmail.com>
2015-07-09 04:07:34 -07:00
W. Trevor King
663f37cb99 core/commands/unixfs/ls: Don't recurse into chunked files
Folks operating at the Unix-filesystem level shouldn't care about that
level of Merkle-DAG detail.  Before this commit we had:

  $ ipfs unixfs ls /ipfs/QmSRCHG21Sbqm3EJG9aEBo4vS7Fqu86pAjqf99MyCdNxZ4/busybox
  /ipfs/QmSRCHG21Sbqm3EJG9aEBo4vS7Fqu86pAjqf99MyCdNxZ4/busybox:
  ... several lines of empty-string names ...

And with this commit we have:

  $ ipfs unixfs ls /ipfs/QmSRCHG21Sbqm3EJG9aEBo4vS7Fqu86pAjqf99MyCdNxZ4/busybox
  /ipfs/QmSRCHG21Sbqm3EJG9aEBo4vS7Fqu86pAjqf99MyCdNxZ4/busybox

I also reworked the argument-prefixing (object.Argument) in the output
marshaller to avoid redundancies like:

  $ ipfs unixfs ls /ipfs/QmSRCHG21Sbqm3EJG9aEBo4vS7Fqu86pAjqf99MyCdNxZ4/busybox
  /ipfs/QmSRCHG21Sbqm3EJG9aEBo4vS7Fqu86pAjqf99MyCdNxZ4/busybox:
  /ipfs/QmSRCHG21Sbqm3EJG9aEBo4vS7Fqu86pAjqf99MyCdNxZ4/busybox

As a side-effect of this rework, we no longer have the trailing blank
line that we used to have after the final directory listing.

The new ErrImplementation is like Python's NotImplementedError, and is
mostly a way to guard against external changes that would need
associated updates in this code.  For example, once we see something
that's neither a file nor a directory, we'll have to update the switch
statement to handle those objects.

License: MIT
Signed-off-by: W. Trevor King <wking@tremily.us>
2015-06-13 13:06:34 -07:00
rht
3547f7ae33 Replace 'var * bytes.Buffer' with '\1 := new(bytes.Buffer)' 2015-05-26 23:18:04 +07:00
Christian Couder
23681727e0 parse: fix parsing optional arg with stdin
License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2015-05-21 00:30:08 +02:00
Christian Couder
be3b7e13e3 parse_test: test command with optional arg
License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2015-05-20 22:47:14 +02:00
Christian Couder
8d6bfec890 parse: improve stdin fix
License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2015-05-20 21:28:41 +02:00
Lars Gierth
2eea1b05b7 parse: fix handling of unwanted stdin
There can be non-terminal (i.e. non-interactive) sessions
that are *not* a pipe, for example:

	ssh user@host ipfs version

In this case, it looks like we should read from stdin.
Parsing stdin is accomplished by deliberately triggering
the parsing loop once.

We didn't previously check whether there is an ArgDef to support
that loop iteration.
2015-05-20 04:25:56 +02:00
Lars Gierth
4e0ca860e9 parse_test: test unwanted stdin 2015-05-20 04:23:43 +02:00
Juan Batiz-Benet
c561c0980b Merge pull request #1239 from rht/master
Add gofmt check
2015-05-19 04:03:23 -04:00
rht
ac7edddb94 Run 'gofmt -s -w' on these files 2015-05-19 06:11:15 +07:00
Christian Couder
275ec7c2a0 parse_test: test stdin enabled and not variadic arg
License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2015-05-18 00:24:13 +02:00
Christian Couder
53a80e255f parse: fix arg number check
This should fix issue #1196 (Can't launch a command line
process from Qt).

The check was bad because it took stdin into account,
but it really shouldn't.

License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2015-05-18 00:03:02 +02:00
Christian Couder
c93d583f02 parse_test: add tests with 2 args and stdin
License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2015-05-17 23:48:56 +02:00
Christian Couder
942e96400b parse: fix parsing stdin args
License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2015-05-17 23:43:24 +02:00
Christian Couder
5503c4cc89 parse_test: improve error messages
License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2015-05-17 23:14:08 +02:00
Christian Couder
97ab64af30 parse: don't use stdin if there are arguments
This should fix issue #1141 (ipfs cat "multihash too short"
error when using stdin) and perhaps others.

License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2015-05-17 21:19:12 +02:00
Christian Couder
ff9cb9ecf4 parse_test: test multiline stdin
License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2015-05-17 20:34:40 +02:00
David Braun
496e7a4b2c Vendor CORS library. 2015-05-10 10:58:37 -07:00
David Braun
f6c6d5de13 Add CORS middleware handler to the API. 2015-05-08 18:41:00 -07:00
Henry
f640ba0089 core: add context.Context param to core.Resolve()
commands/object: remove objectData() and objectLinks() helpers
resolver: added context parameters
sharness: $HASH carried the \r from the http protocol with
sharness: write curl output to individual files
http gw: break PUT handler until PR#1191
2015-05-08 03:14:32 +02:00