Skip to content

Commit f1f3b3e

Browse files
author
Jan Karres
authored
Merge pull request #1 from jankarres/methode-delete
Allow HTTP body for DELETE request
2 parents 821eeb0 + e655b88 commit f1f3b3e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ else if (value.equalsIgnoreCase("utf8"))
239239
}
240240
}
241241

242-
if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch")) {
242+
if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch") || method.equalsIgnoreCase("delete")) {
243243
String cType = getHeaderIgnoreCases(mheaders, "Content-Type").toLowerCase();
244244

245245
if(rawRequestBodyArray != null) {
@@ -300,7 +300,7 @@ else if(cType.isEmpty()) {
300300
break;
301301

302302
case WithoutBody:
303-
if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch"))
303+
if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch") || method.equalsIgnoreCase("delete"))
304304
{
305305
builder.method(method, RequestBody.create(null, new byte[0]));
306306
}

ios/RNFetchBlobReqBuilder.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ +(void) buildOctetRequest:(NSDictionary *)options
9999
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
100100
NSMutableData * blobData;
101101
long size = -1;
102-
// if method is POST, PUT or PATCH, convert data string format
103-
if([[method lowercaseString] isEqualToString:@"post"] || [[method lowercaseString] isEqualToString:@"put"] || [[method lowercaseString] isEqualToString:@"patch"]) {
102+
// if method is POST, PUT, PATCH or DELETE, convert data string format
103+
if([[method lowercaseString] isEqualToString:@"post"] || [[method lowercaseString] isEqualToString:@"put"] || [[method lowercaseString] isEqualToString:@"patch"] || [[method lowercaseString] isEqualToString:@"delete"]) {
104104
// generate octet-stream body
105105
if(body != nil) {
106106
__block NSString * cType = [[self class] getHeaderIgnoreCases:@"content-type" fromHeaders:mheaders];
@@ -117,7 +117,7 @@ +(void) buildOctetRequest:(NSDictionary *)options
117117
orgPath = [RNFetchBlobFS getPathOfAsset:orgPath];
118118
if([orgPath hasPrefix:AL_PREFIX])
119119
{
120-
120+
121121
[RNFetchBlobFS readFile:orgPath encoding:nil onComplete:^(NSData *content, NSString * err) {
122122
if(err != nil)
123123
{
@@ -131,7 +131,7 @@ +(void) buildOctetRequest:(NSDictionary *)options
131131
onComplete(request, [content length]);
132132
}
133133
}];
134-
134+
135135
return;
136136
}
137137
size = [[[NSFileManager defaultManager] attributesOfItemAtPath:orgPath error:nil] fileSize];

0 commit comments

Comments
 (0)