@@ -153,6 +153,14 @@ func TestGatewayGet(t *testing.T) {
153
153
ns ["/ipns/double.example.com" ] = path .FromString ("/ipns/working.example.com" )
154
154
ns ["/ipns/triple.example.com" ] = path .FromString ("/ipns/double.example.com" )
155
155
ns ["/ipns/broken.example.com" ] = path .FromString ("/ipns/" + k )
156
+ // We picked .man because:
157
+ // 1. It's a valid TLD.
158
+ // 2. Go treats it as the file extension for "man" files (even though
159
+ // nobody actually *uses* this extension, AFAIK).
160
+ //
161
+ // Unfortunately, this may not work on all platforms as file type
162
+ // detection is platform dependent.
163
+ ns ["/ipns/example.man" ] = path .FromString ("/ipfs/" + k )
156
164
157
165
t .Log (ts .URL )
158
166
for _ , test := range []struct {
@@ -175,6 +183,8 @@ func TestGatewayGet(t *testing.T) {
175
183
{"working.example.com" , "/ipfs/" + k , http .StatusNotFound , "ipfs resolve -r /ipns/working.example.com/ipfs/" + k + ": no link by that name\n " },
176
184
{"broken.example.com" , "/" , http .StatusNotFound , "ipfs resolve -r /ipns/broken.example.com/: " + namesys .ErrResolveFailed .Error () + "\n " },
177
185
{"broken.example.com" , "/ipfs/" + k , http .StatusNotFound , "ipfs resolve -r /ipns/broken.example.com/ipfs/" + k + ": " + namesys .ErrResolveFailed .Error () + "\n " },
186
+ // This test case ensures we don't treat the TLD as a file extension.
187
+ {"example.man" , "/" , http .StatusOK , "fnord" },
178
188
} {
179
189
var c http.Client
180
190
r , err := http .NewRequest ("GET" , ts .URL + test .path , nil )
@@ -190,6 +200,10 @@ func TestGatewayGet(t *testing.T) {
190
200
continue
191
201
}
192
202
defer resp .Body .Close ()
203
+ contentType := resp .Header .Get ("Content-Type" )
204
+ if contentType != "text/plain; charset=utf-8" {
205
+ t .Errorf ("expected content type to be text/plain, got %s" , contentType )
206
+ }
193
207
if resp .StatusCode != test .status {
194
208
t .Errorf ("got %d, expected %d from %s" , resp .StatusCode , test .status , urlstr )
195
209
continue
0 commit comments