File tree 2 files changed +38
-35
lines changed
2 files changed +38
-35
lines changed Original file line number Diff line number Diff line change @@ -11,31 +11,30 @@ test_description="test http requests made by cli"
11
11
test_init_ipfs
12
12
13
13
test_expect_success " start nc" '
14
- rm -f nc_out nc_status nc_in && mkfifo nc_in nc_status
15
- nc -v -l 127.0.0.1 5005 < nc_in > nc_out 2>nc_status &
14
+ rm -f nc_outp nc_inp nc_statusp && mkfifo nc_inp nc_outp nc_statusp
15
+ nc -v -l 127.0.0.1 5005 <nc_inp >nc_outp 2>nc_statusp &
16
16
NCPID=$!
17
+ exec 6>nc_inp 7<nc_outp
17
18
18
- # Needed to "prime" nc
19
- echo -n "" > nc_in &&
20
-
21
- # Wait for it to start
22
- head -1 nc_status
19
+ head -1 <nc_statusp
23
20
'
24
21
25
22
test_expect_success " can make http request against nc server" '
26
- cat >nc_in <<EOF
27
- HTTP/1.1 200 OK
28
- Content-Type: text/plain
29
- Content-Length: 1
30
-
31
- .
32
- EOF
33
- head -1 nc_status & # consume "connected message"
34
- ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005
35
- '
23
+ ipfs cat /ipfs/Qmabcdef --api /ip4/127.0.0.1/tcp/5005 &
24
+ IPFSPID=$!
25
+
26
+ head -1 <nc_statusp
27
+
28
+ # handle request
29
+ echo "HTTP/1.1 200 OK" >&6 &&
30
+ echo "Content-Type: text/plain" >&6 &&
31
+ echo "Content-Length: 0" >&6 &&
32
+ echo "" >&6 &&
33
+ sed -n "0,/^$/p" <&7 > nc_out &&
34
+ exec 6<&- # Keep connection open till *after* we have the full request.
36
35
37
- test_expect_success " wait for nc to exit " '
38
- wait $NCPID
36
+ # Wait for IPFS and netcat
37
+ wait $IPFSPID $ NCPID
39
38
'
40
39
41
40
test_expect_success " output does not contain multipart info" '
Original file line number Diff line number Diff line change @@ -11,31 +11,35 @@ test_description="test dns resolution of api endpoint by cli"
11
11
test_init_ipfs
12
12
13
13
test_expect_success " start nc" '
14
- rm -f nc_out nc_status nc_in && mkfifo nc_in nc_status
15
- nc -v -l 127.0.0.1 5006 < nc_in > nc_out 2>nc_status &
14
+ rm -f nc_outp nc_inp nc_statusp && mkfifo nc_inp nc_outp nc_statusp
15
+ nc -v -l 127.0.0.1 5005 <nc_inp >nc_outp 2>nc_statusp &
16
16
NCPID=$!
17
+ exec 6>nc_inp 7<nc_outp
17
18
18
- # Needed to "prime" nc
19
- echo -n "" > nc_in &&
20
-
21
- # Wait for it to start
22
- head -1 nc_status
19
+ head -1 <nc_statusp
23
20
'
24
21
25
22
test_expect_success " can make http request against dns resolved nc server" '
26
- cat >nc_in <<EOF
27
- HTTP/1.1 200 OK
28
- Content-Type: text/plain
29
- Content-Length: 1
30
-
31
- .
32
- EOF
33
- head -1 nc_status & # consume "connected message"
34
- ipfs cat /ipfs/Qmabcdef --api /dns4/localhost/tcp/5006
23
+ ipfs cat /ipfs/Qmabcdef --api /dns4/localhost/tcp/5006 &
24
+ IPFSPID=$!
25
+
26
+ head -1 <nc_statusp
27
+
28
+ # handle request
29
+ echo "HTTP/1.1 200 OK" >&6 &&
30
+ echo "Content-Type: text/plain" >&6 &&
31
+ echo "Content-Length: 0" >&6 &&
32
+ echo "" >&6 &&
33
+ sed -n "0,/^$/p" <&7 > nc_out &&
34
+ exec 6<&- # Keep connection open till *after* we have the full request.
35
+
36
+ # Wait for IPFS and netcat
37
+ wait $IPFSPID $NCPID
35
38
'
36
39
37
40
test_expect_success " wait for nc to exit" '
38
41
wait $NCPID
42
+ cat nc_out
39
43
'
40
44
41
45
test_expect_success " request was received by local nc server" '
You can’t perform that action at this time.
0 commit comments