Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Allow HTTP body for DELETE request #592

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
Original file line number Diff line number Diff line change
@@ -239,7 +239,7 @@ else if (value.equalsIgnoreCase("utf8"))
}
}

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

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

case WithoutBody:
if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch"))
if(method.equalsIgnoreCase("post") || method.equalsIgnoreCase("put") || method.equalsIgnoreCase("patch") || method.equalsIgnoreCase("delete"))
{
builder.method(method, RequestBody.create(null, new byte[0]));
}
8 changes: 4 additions & 4 deletions ios/RNFetchBlobReqBuilder.m
Original file line number Diff line number Diff line change
@@ -99,8 +99,8 @@ +(void) buildOctetRequest:(NSDictionary *)options
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSMutableData * blobData;
long size = -1;
// if method is POST, PUT or PATCH, convert data string format
if([[method lowercaseString] isEqualToString:@"post"] || [[method lowercaseString] isEqualToString:@"put"] || [[method lowercaseString] isEqualToString:@"patch"]) {
// if method is POST, PUT, PATCH or DELETE, convert data string format
if([[method lowercaseString] isEqualToString:@"post"] || [[method lowercaseString] isEqualToString:@"put"] || [[method lowercaseString] isEqualToString:@"patch"] || [[method lowercaseString] isEqualToString:@"delete"]) {
// generate octet-stream body
if(body != nil) {
__block NSString * cType = [[self class] getHeaderIgnoreCases:@"content-type" fromHeaders:mheaders];
@@ -117,7 +117,7 @@ +(void) buildOctetRequest:(NSDictionary *)options
orgPath = [RNFetchBlobFS getPathOfAsset:orgPath];
if([orgPath hasPrefix:AL_PREFIX])
{

[RNFetchBlobFS readFile:orgPath encoding:nil onComplete:^(NSData *content, NSString * err) {
if(err != nil)
{
@@ -131,7 +131,7 @@ +(void) buildOctetRequest:(NSDictionary *)options
onComplete(request, [content length]);
}
}];

return;
}
size = [[[NSFileManager defaultManager] attributesOfItemAtPath:orgPath error:nil] fileSize];