@@ -439,14 +439,22 @@ open class DavResource @JvmOverloads constructor(
439
439
* @param ifETag value of `If-Match` header to set, or null to omit
440
440
* @param ifScheduleTag value of `If-Schedule-Tag-Match` header to set, or null to omit
441
441
* @param ifNoneMatch indicates whether `If-None-Match: *` ("don't overwrite anything existing") header shall be sent
442
+ * @param headers additional headers to send
442
443
* @param callback called with server response unless an exception is thrown
443
444
*
444
445
* @throws IOException on I/O error
445
446
* @throws HttpException on HTTP error
446
447
* @throws DavException on HTTPS -> HTTP redirect
447
448
*/
448
449
@Throws(IOException ::class , HttpException ::class )
449
- fun put (body : RequestBody , ifETag : String? = null, ifScheduleTag : String? = null, ifNoneMatch : Boolean = false, callback : ResponseCallback ) {
450
+ fun put (
451
+ body : RequestBody ,
452
+ ifETag : String? = null,
453
+ ifScheduleTag : String? = null,
454
+ ifNoneMatch : Boolean = false,
455
+ headers : Map <String , String > = emptyMap(),
456
+ callback : ResponseCallback
457
+ ) {
450
458
followRedirects {
451
459
val builder = Request .Builder ()
452
460
.put(body)
@@ -462,6 +470,10 @@ open class DavResource @JvmOverloads constructor(
462
470
// don't overwrite anything existing
463
471
builder.header(" If-None-Match" , " *" )
464
472
473
+ // Add custom headers
474
+ for ((key, value) in headers)
475
+ builder.header(key, value)
476
+
465
477
httpClient.newCall(builder.build()).execute()
466
478
}.use { response ->
467
479
checkStatus(response)
@@ -477,6 +489,7 @@ open class DavResource @JvmOverloads constructor(
477
489
*
478
490
* @param ifETag value of `If-Match` header to set, or null to omit
479
491
* @param ifScheduleTag value of `If-Schedule-Tag-Match` header to set, or null to omit
492
+ * @param headers additional headers to send
480
493
* @param callback called with server response unless an exception is thrown
481
494
*
482
495
* @throws IOException on I/O error
@@ -485,7 +498,12 @@ open class DavResource @JvmOverloads constructor(
485
498
* @throws DavException on HTTPS -> HTTP redirect
486
499
*/
487
500
@Throws(IOException ::class , HttpException ::class )
488
- fun delete (ifETag : String? = null, ifScheduleTag : String? = null, callback : ResponseCallback ) {
501
+ fun delete (
502
+ ifETag : String? = null,
503
+ ifScheduleTag : String? = null,
504
+ headers : Map <String , String > = emptyMap(),
505
+ callback : ResponseCallback
506
+ ) {
489
507
followRedirects {
490
508
val builder = Request .Builder ()
491
509
.delete()
@@ -495,6 +513,10 @@ open class DavResource @JvmOverloads constructor(
495
513
if (ifScheduleTag != null )
496
514
builder.header(" If-Schedule-Tag-Match" , QuotedStringUtils .asQuotedString(ifScheduleTag))
497
515
516
+ // Add custom headers
517
+ for ((key, value) in headers)
518
+ builder.header(key, value)
519
+
498
520
httpClient.newCall(builder.build()).execute()
499
521
}.use { response ->
500
522
checkStatus(response)
0 commit comments