Skip to content

Commit 55b170a

Browse files
Add Content-Length to the itunes request applications service request (#2882)
1 parent c1c3ac4 commit 55b170a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/services/itmstransporter-service.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ export class ITMSTransporterService implements IITMSTransporterService {
5858
contentDeliveryResponse = await this.$httpClient.httpRequest({
5959
url: "https://contentdelivery.itunes.apple.com/WebObjects/MZLabelService.woa/json/MZITunesProducerService",
6060
method: "POST",
61-
body: requestBody
61+
body: requestBody,
62+
headers: {
63+
"Content-Length": requestBody.length
64+
}
6265
}),
6366
contentDeliveryBody: IContentDeliveryBody = JSON.parse(contentDeliveryResponse.body);
6467

@@ -170,12 +173,12 @@ export class ITMSTransporterService implements IITMSTransporterService {
170173
return this._itmsTransporterPath;
171174
}
172175

173-
private getContentDeliveryRequestBody(credentials: ICredentials): string {
176+
private getContentDeliveryRequestBody(credentials: ICredentials): Buffer {
174177
// All of those values except credentials are hardcoded
175178
// Apple's content delivery API is very picky with handling requests
176179
// and if only one of these ends up missing the API returns
177180
// a response with 200 status code and an error
178-
return JSON.stringify({
181+
return Buffer.from(JSON.stringify({
179182
id: "1", // magic number
180183
jsonrpc: "2.0",
181184
method: "lookupSoftwareApplications",
@@ -186,7 +189,7 @@ export class ITMSTransporterService implements IITMSTransporterService {
186189
Application: "Application Loader",
187190
OSIdentifier: "Mac OS X 10.8.5 (x86_64)"
188191
}
189-
});
192+
}), "utf8");
190193
}
191194

192195
private getITMSMetadataXml(appleId: string, ipaFileName: string, ipaFileHash: string, ipaFileSize: number): string {

0 commit comments

Comments
 (0)