@@ -319,6 +319,44 @@ func TestPost(t *testing.T) {
319
319
}).Run (handler , t )
320
320
})
321
321
322
+ SubTest (t , "RespectForwardedWithQuotes" , func (t * testing.T , store * MockFullDataStore , composer * StoreComposer ) {
323
+ // See https://github.com/tus/tusd/issues/809
324
+ ctrl := gomock .NewController (t )
325
+ defer ctrl .Finish ()
326
+ upload := NewMockFullUpload (ctrl )
327
+
328
+ gomock .InOrder (
329
+ store .EXPECT ().NewUpload (context .Background (), FileInfo {
330
+ Size : 300 ,
331
+ MetaData : map [string ]string {},
332
+ }).Return (upload , nil ),
333
+ upload .EXPECT ().GetInfo (context .Background ()).Return (FileInfo {
334
+ ID : "foo" ,
335
+ Size : 300 ,
336
+ MetaData : map [string ]string {},
337
+ }, nil ),
338
+ )
339
+
340
+ handler , _ := NewHandler (Config {
341
+ StoreComposer : composer ,
342
+ BasePath : "/files/" ,
343
+ RespectForwardedHeaders : true ,
344
+ })
345
+
346
+ (& httpTest {
347
+ Method : "POST" ,
348
+ ReqHeader : map [string ]string {
349
+ "Tus-Resumable" : "1.0.0" ,
350
+ "Upload-Length" : "300" ,
351
+ "Forwarded" : `Forwarded: for=192.168.10.112;host="upload.example.tld:8443";proto=https` ,
352
+ },
353
+ Code : http .StatusCreated ,
354
+ ResHeader : map [string ]string {
355
+ "Location" : "https://upload.example.tld:8443/files/foo" ,
356
+ },
357
+ }).Run (handler , t )
358
+ })
359
+
322
360
SubTest (t , "FilterForwardedProtocol" , func (t * testing.T , store * MockFullDataStore , composer * StoreComposer ) {
323
361
ctrl := gomock .NewController (t )
324
362
defer ctrl .Finish ()
0 commit comments