Commit Graph

125 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
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
Jeromy Johnson
98559d0e0b put comment back 2015-07-28 08:44:35 -07: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
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
Tor Arne Vestbø
cc45e21e4c Teach http client to abort channel streaming on context cancellation
When the response includes the X-Chunked-Output header, we treat that
as channel output, and fire up a goroutine to decode the chunks. This
routine need to look for context cancellation so that it can exit
cleanly.
2015-04-20 16:35:35 +02:00
Tor Arne Vestbø
661fb0a4b5 Teach http client to cancel request on context cancellation
The context may be cancelled while a request is in flight. We need to
handle this and cancel the request. The code is based on the ideas
from https://blog.golang.org/context
2015-04-20 16:35:35 +02:00
Ho-Sheng Hsiao
bf22aeec0a Reorged imports from jbenet/go-ipfs to ipfs/go-ipfs
- Modified Godeps/Godeps.json by hand
- [TEST] Updated welcome docs hash to sharness
- [TEST] Updated contact doc
- [TEST] disabled breaking test (t0080-repo refs local)
2015-03-31 12:52:25 -07:00
Henry
92d08db7a5 rewrote import paths of go.net/context to use golang.org/x/context
- updated go-ctxgroup and goprocess
ctxgroup: AddChildGroup was changed to AddChild. Used in two files:
- p2p/net/mock/mock_net.go
- routing/dht/dht.go

- updated context from hg repo to git
prev. commit in hg was ad01a6fcc8a19d3a4478c836895ffe883bd2ceab. (context: make parentCancelCtx iterative)
represents commit 84f8955a887232b6308d79c68b8db44f64df455c in git repo

- updated context to master (b6fdb7d8a4ccefede406f8fe0f017fb58265054c)

Aaron Jacobs (2):
net/context: Don't accept a context in the DoSomethingSlow example.
context: Be clear that users must cancel the result of WithCancel.

Andrew Gerrand (1):
go.net: use golang.org/x/... import paths

Bryan C. Mills (1):
net/context: Don't leak goroutines in Done example.

Damien Neil (1):
context: fix removal of cancelled timer contexts from parent

David Symonds (2):
context: Fix WithValue example code.
net: add import comments.

Sameer Ajmani (1):
context: fix TestAllocs to account for ints in interfaces
2015-02-25 11:58:19 +01:00
Matt Bell
e8bbf1dcdf commands/http: Made command HTTP API only accept requests from referers on the same server 2015-02-04 18:46:59 -08:00
Matt Bell
a7de81b818 commands: URL escape filenames in multipart files, resolves #654 2015-02-04 16:53:24 -08:00
Juan Batiz-Benet
58f39687cf logs: removed all log.Errors unhelpful to users
Let's save log.Error for things the user can take action on.
Moved all our diagnostics to log.Debug. We can ideally reduce them
even further.
2015-02-03 01:06:07 -08:00
Juan Batiz-Benet
4334f6fda3 Merge pull request #613 from jbenet/progress-bars
Progress Bars
2015-01-23 22:20:34 -08:00
Matt Bell
5589021a1d commands/http: Fixed panics when unmarshaling command output without a set Command.Type 2015-01-23 19:11:56 -08:00
Matt Bell
8ca8d6ef71 commands/files: Added PeekFile and StatFile interfaces
squash! commands/files: Added PeekFile and StatFile interfaces

commands/http: Updated test
2015-01-23 18:29:30 -08:00
Matt Bell
6adebfad11 commands: Added Length field to Response
squash! commands: Added Length field to Response

commands/http: client: Fixed error on unset length
2015-01-23 18:29:29 -08:00
Matt Bell
31ae178078 commands: Support outputting <-chan interface{} 2015-01-21 04:28:02 +00:00
Matt Bell
dbb5118d76 commands/files: Fixed tests 2015-01-13 22:50:54 -08:00
Matt Bell
a2b3402aa4 commands/http: Fixed package import in tests 2015-01-13 22:50:54 -08:00
Matt Bell
7a579bbf79 commands: Moved files code into 'commands/files' subpackage 2015-01-13 22:50:53 -08:00
Brian Tiger Chow
5b3164de5c refactor(repo/config) move config under repo 2015-01-13 03:09:30 -08:00
Juan Batiz-Benet
322d6d0b05 cmds: use flushCopy instrad of copychunks
@mappum would this work?
2015-01-11 20:52:33 -08:00
Juan Batiz-Benet
ddd7540186 cmds: flush output on standard readers
cc @mappum can we do this for the copyChunks case?
2015-01-11 20:52:33 -08:00
Juan Batiz-Benet
0e2a554c8d cmds: fix error header output
using Header().Set after WriteHeader() has no effect.
cc @mappum
2015-01-11 20:52:33 -08:00
Matt Bell
77e5742ac7 commands/http: client: Decode values into a new instance of the output type 2015-01-06 15:53:49 -08:00