Skip to content
Merged
Show file tree
Hide file tree
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: 3 additions & 1 deletion src/main/java/com/microsoft/graph/http/CoreHttpProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ public <Result, Body> Request getHttpRequest(final IHttpRequest request,
// This ensures that the Content-Length header is properly set
if (request.getHttpMethod() == HttpMethod.POST) {
bytesToWrite = new byte[0];
contenttype = Constants.BINARY_CONTENT_TYPE;
if(contenttype == null) {
contenttype = Constants.BINARY_CONTENT_TYPE;
}
}
else {
bytesToWrite = null;
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/com/microsoft/graph/functional/UserTests.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
package com.microsoft.graph.functional;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import okhttp3.Request;

import com.microsoft.graph.http.HttpMethod;
import com.microsoft.graph.models.extensions.Drive;
import com.microsoft.graph.models.extensions.DriveItem;
import com.microsoft.graph.models.extensions.IGraphServiceClient;
import com.microsoft.graph.models.extensions.ProfilePhoto;
import com.microsoft.graph.models.extensions.User;
import com.microsoft.graph.options.HeaderOption;
import com.microsoft.graph.options.Option;
import com.microsoft.graph.requests.extensions.IContactCollectionPage;
import com.microsoft.graph.requests.extensions.IDirectoryObjectCollectionWithReferencesPage;
import com.microsoft.graph.requests.extensions.IDriveItemCollectionPage;
Expand Down Expand Up @@ -164,4 +171,18 @@ public void meMemberof() {
assertNotNull(page);
}

@Test
public void emptyPostContentType() {
final String contentTypeValue = "application/json";
final HeaderOption ctype = new HeaderOption("Content-Type", contentTypeValue);
final ArrayList<Option> options = new ArrayList<>();
options.add(ctype);
final Request request = graphServiceClient.me()
.revokeSignInSessions()
.buildRequest(options)
.withHttpMethod(HttpMethod.POST)
.getHttpRequest();
assertEquals(contentTypeValue, request.body().contentType().toString());
}

}