}
} else {
assertEquals(TEST_RESUMABLE_REQUEST_URL, url);
}
return new MockLowLevelHttpRequest() {
@Override
public LowLevelHttpResponse execute() {
lowLevelExecCalls++;
if (!directUploadEnabled) {
// Assert that the required headers are set.
if (!contentLengthNotSpecified) {
assertEquals(Integer.toString(contentLength),
getFirstHeaderValue("x-upload-content-length"));
}
assertEquals(TEST_CONTENT_TYPE, getFirstHeaderValue("x-upload-content-type"));
}
if (assertTestHeaders) {
assertEquals("test-header-value", getFirstHeaderValue("test-header-name"));
}
// This is the initiation call.
MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
assertFalse(directUploadEnabled && testIOException);
if (directUploadEnabled && testServerError && lowLevelExecCalls == 1) {
// send a server error in the 1st request of a direct upload
response.setStatusCode(500);
} else if (testAuthenticationError) {
// Return 404.
response.setStatusCode(404);
} else {
// Return 200 with the upload URI.
response.setStatusCode(200);
if (!directUploadEnabled) {
response.addHeader("Location", TEST_UPLOAD_URL);
}
}
return response;
}
};
}
assertEquals(TEST_UPLOAD_URL, url);
assertEquals("PUT", name);
return new MockLowLevelHttpRequest() {
@Override
public LowLevelHttpResponse execute() throws IOException {
lowLevelExecCalls++;
MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
String contentRangeHeader = getFirstHeaderValue("Content-Range");