@aws-sdk/core 3.940.0 → 3.946.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist-cjs/index.js +164 -109
  2. package/dist-cjs/submodules/protocols/index.js +164 -109
  3. package/dist-es/submodules/protocols/ProtocolLib.js +20 -3
  4. package/dist-es/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.js +11 -3
  5. package/dist-es/submodules/protocols/json/AwsJson1_0Protocol.js +2 -1
  6. package/dist-es/submodules/protocols/json/AwsJson1_1Protocol.js +2 -1
  7. package/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +14 -11
  8. package/dist-es/submodules/protocols/json/JsonShapeDeserializer.js +30 -26
  9. package/dist-es/submodules/protocols/json/JsonShapeSerializer.js +75 -53
  10. package/dist-es/submodules/protocols/query/AwsQueryProtocol.js +3 -8
  11. package/dist-es/submodules/protocols/structIterator.js +5 -3
  12. package/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +3 -1
  13. package/dist-types/submodules/protocols/ProtocolLib.d.ts +6 -0
  14. package/dist-types/submodules/protocols/json/AwsJson1_0Protocol.d.ts +3 -1
  15. package/dist-types/submodules/protocols/json/AwsJson1_1Protocol.d.ts +3 -1
  16. package/dist-types/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +2 -1
  17. package/dist-types/submodules/protocols/json/JsonShapeDeserializer.d.ts +1 -1
  18. package/dist-types/submodules/protocols/json/JsonShapeSerializer.d.ts +12 -3
  19. package/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +4 -0
  20. package/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +3 -0
  21. package/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +3 -0
  22. package/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +2 -0
  23. package/dist-types/ts3.4/submodules/protocols/json/JsonShapeDeserializer.d.ts +1 -1
  24. package/dist-types/ts3.4/submodules/protocols/json/JsonShapeSerializer.d.ts +9 -3
  25. package/package.json +3 -3
package/dist-cjs/index.js CHANGED
@@ -406,9 +406,18 @@ class ProtocolLib {
406
406
  const msg = exception.Message ?? additions.Message;
407
407
  const error = smithyClient.decorateServiceException(exception, additions);
408
408
  if (msg) {
409
- error.Message = msg;
410
409
  error.message = msg;
411
410
  }
411
+ error.Error = {
412
+ ...error.Error,
413
+ Type: error.Error.Type,
414
+ Code: error.Error.Code,
415
+ Message: error.Error.message ?? error.Error.Message ?? msg,
416
+ };
417
+ const reqId = error.$metadata.requestId;
418
+ if (reqId) {
419
+ error.RequestId = reqId;
420
+ }
412
421
  return error;
413
422
  }
414
423
  return smithyClient.decorateServiceException(exception, additions);
@@ -424,7 +433,7 @@ class ProtocolLib {
424
433
  };
425
434
  Object.assign(output, Error);
426
435
  for (const [k, v] of entries) {
427
- Error[k] = v;
436
+ Error[k === "message" ? "Message" : k] = v;
428
437
  }
429
438
  delete Error.__type;
430
439
  output.Error = Error;
@@ -441,6 +450,14 @@ class ProtocolLib {
441
450
  errorData.Code = queryCompatErrorData.Code;
442
451
  }
443
452
  }
453
+ findQueryCompatibleError(registry, errorName) {
454
+ try {
455
+ return registry.getSchema(errorName);
456
+ }
457
+ catch (e) {
458
+ return registry.find((schema$1) => schema.NormalizedSchema.of(schema$1).getMergedTraits().awsQueryError?.[0] === errorName);
459
+ }
460
+ }
444
461
  }
445
462
 
446
463
  class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
@@ -462,15 +479,23 @@ class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
462
479
  if (this.awsQueryCompatible) {
463
480
  this.mixin.setQueryCompatError(dataObject, response);
464
481
  }
465
- const errorName = cbor.loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
466
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata);
482
+ const errorName = (() => {
483
+ const compatHeader = response.headers["x-amzn-query-error"];
484
+ if (compatHeader && this.awsQueryCompatible) {
485
+ return compatHeader.split(";")[0];
486
+ }
487
+ return cbor.loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
488
+ })();
489
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorName, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
467
490
  const ns = schema.NormalizedSchema.of(errorSchema);
468
491
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
469
492
  const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
470
493
  const exception = new ErrorCtor(message);
471
494
  const output = {};
472
495
  for (const [name, member] of ns.structIterator()) {
473
- output[name] = this.deserializer.readValue(member, dataObject[name]);
496
+ if (dataObject[name] != null) {
497
+ output[name] = this.deserializer.readValue(member, dataObject[name]);
498
+ }
474
499
  }
475
500
  if (this.awsQueryCompatible) {
476
501
  this.mixin.queryCompatOutput(dataObject, output);
@@ -546,7 +571,8 @@ function* serializingStructIterator(ns, sourceObject) {
546
571
  const struct = ns.getSchema();
547
572
  for (let i = 0; i < struct[4].length; ++i) {
548
573
  const key = struct[4][i];
549
- const memberNs = new schema.NormalizedSchema([struct[5][i], 0], key);
574
+ const memberSchema = struct[5][i];
575
+ const memberNs = new schema.NormalizedSchema([memberSchema, 0], key);
550
576
  if (!(key in sourceObject) && !memberNs.isIdempotencyToken()) {
551
577
  continue;
552
578
  }
@@ -558,13 +584,14 @@ function* deserializingStructIterator(ns, sourceObject, nameTrait) {
558
584
  return;
559
585
  }
560
586
  const struct = ns.getSchema();
561
- let keysRemaining = Object.keys(sourceObject).length;
587
+ let keysRemaining = Object.keys(sourceObject).filter((k) => k !== "__type").length;
562
588
  for (let i = 0; i < struct[4].length; ++i) {
563
589
  if (keysRemaining === 0) {
564
590
  break;
565
591
  }
566
592
  const key = struct[4][i];
567
- const memberNs = new schema.NormalizedSchema([struct[5][i], 0], key);
593
+ const memberSchema = struct[5][i];
594
+ const memberNs = new schema.NormalizedSchema([memberSchema, 0], key);
568
595
  let serializationKey = key;
569
596
  if (nameTrait) {
570
597
  serializationKey = memberNs.getMergedTraits()[nameTrait] ?? key;
@@ -666,38 +693,40 @@ class JsonShapeDeserializer extends SerdeContextConfig {
666
693
  _read(schema$1, value) {
667
694
  const isObject = value !== null && typeof value === "object";
668
695
  const ns = schema.NormalizedSchema.of(schema$1);
669
- if (ns.isListSchema() && Array.isArray(value)) {
670
- const listMember = ns.getValueSchema();
671
- const out = [];
672
- const sparse = !!ns.getMergedTraits().sparse;
673
- for (const item of value) {
674
- if (sparse || item != null) {
675
- out.push(this._read(listMember, item));
696
+ if (isObject) {
697
+ if (ns.isStructSchema()) {
698
+ const out = {};
699
+ for (const [memberName, memberSchema] of deserializingStructIterator(ns, value, this.settings.jsonName ? "jsonName" : false)) {
700
+ const fromKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
701
+ const deserializedValue = this._read(memberSchema, value[fromKey]);
702
+ if (deserializedValue != null) {
703
+ out[memberName] = deserializedValue;
704
+ }
676
705
  }
706
+ return out;
677
707
  }
678
- return out;
679
- }
680
- else if (ns.isMapSchema() && isObject) {
681
- const mapMember = ns.getValueSchema();
682
- const out = {};
683
- const sparse = !!ns.getMergedTraits().sparse;
684
- for (const [_k, _v] of Object.entries(value)) {
685
- if (sparse || _v != null) {
686
- out[_k] = this._read(mapMember, _v);
708
+ if (Array.isArray(value) && ns.isListSchema()) {
709
+ const listMember = ns.getValueSchema();
710
+ const out = [];
711
+ const sparse = !!ns.getMergedTraits().sparse;
712
+ for (const item of value) {
713
+ if (sparse || item != null) {
714
+ out.push(this._read(listMember, item));
715
+ }
687
716
  }
717
+ return out;
688
718
  }
689
- return out;
690
- }
691
- else if (ns.isStructSchema() && isObject) {
692
- const out = {};
693
- for (const [memberName, memberSchema] of deserializingStructIterator(ns, value, this.settings.jsonName ? "jsonName" : false)) {
694
- const fromKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
695
- const deserializedValue = this._read(memberSchema, value[fromKey]);
696
- if (deserializedValue != null) {
697
- out[memberName] = deserializedValue;
719
+ if (ns.isMapSchema()) {
720
+ const mapMember = ns.getValueSchema();
721
+ const out = {};
722
+ const sparse = !!ns.getMergedTraits().sparse;
723
+ for (const [_k, _v] of Object.entries(value)) {
724
+ if (sparse || _v != null) {
725
+ out[_k] = this._read(mapMember, _v);
726
+ }
698
727
  }
728
+ return out;
699
729
  }
700
- return out;
701
730
  }
702
731
  if (ns.isBlobSchema() && typeof value === "string") {
703
732
  return utilBase64.fromBase64(value);
@@ -708,6 +737,7 @@ class JsonShapeDeserializer extends SerdeContextConfig {
708
737
  if (isJson) {
709
738
  return serde.LazyJsonString.from(value);
710
739
  }
740
+ return value;
711
741
  }
712
742
  if (ns.isTimestampSchema() && value != null) {
713
743
  const format = protocols.determineTimestampFormat(ns, this.settings);
@@ -745,6 +775,7 @@ class JsonShapeDeserializer extends SerdeContextConfig {
745
775
  case "NaN":
746
776
  return NaN;
747
777
  }
778
+ return value;
748
779
  }
749
780
  if (ns.isDocumentSchema()) {
750
781
  if (isObject) {
@@ -816,6 +847,7 @@ class JsonReplacer {
816
847
  class JsonShapeSerializer extends SerdeContextConfig {
817
848
  settings;
818
849
  buffer;
850
+ useReplacer = false;
819
851
  rootSchema;
820
852
  constructor(settings) {
821
853
  super();
@@ -832,9 +864,13 @@ class JsonShapeSerializer extends SerdeContextConfig {
832
864
  }
833
865
  }
834
866
  flush() {
835
- const { rootSchema } = this;
867
+ const { rootSchema, useReplacer } = this;
836
868
  this.rootSchema = undefined;
869
+ this.useReplacer = false;
837
870
  if (rootSchema?.isStructSchema() || rootSchema?.isDocumentSchema()) {
871
+ if (!useReplacer) {
872
+ return JSON.stringify(this.buffer);
873
+ }
838
874
  const replacer = new JsonReplacer();
839
875
  return replacer.replaceInJson(JSON.stringify(this.buffer, replacer.createReplacer(), 0));
840
876
  }
@@ -843,68 +879,68 @@ class JsonShapeSerializer extends SerdeContextConfig {
843
879
  _write(schema$1, value, container) {
844
880
  const isObject = value !== null && typeof value === "object";
845
881
  const ns = schema.NormalizedSchema.of(schema$1);
846
- if (ns.isListSchema() && Array.isArray(value)) {
847
- const listMember = ns.getValueSchema();
848
- const out = [];
849
- const sparse = !!ns.getMergedTraits().sparse;
850
- for (const item of value) {
851
- if (sparse || item != null) {
852
- out.push(this._write(listMember, item));
882
+ if (isObject) {
883
+ if (ns.isStructSchema()) {
884
+ const out = {};
885
+ for (const [memberName, memberSchema] of serializingStructIterator(ns, value)) {
886
+ const serializableValue = this._write(memberSchema, value[memberName], ns);
887
+ if (serializableValue !== undefined) {
888
+ const jsonName = memberSchema.getMergedTraits().jsonName;
889
+ const targetKey = this.settings.jsonName ? jsonName ?? memberName : memberName;
890
+ out[targetKey] = serializableValue;
891
+ }
853
892
  }
893
+ return out;
854
894
  }
855
- return out;
856
- }
857
- else if (ns.isMapSchema() && isObject) {
858
- const mapMember = ns.getValueSchema();
859
- const out = {};
860
- const sparse = !!ns.getMergedTraits().sparse;
861
- for (const [_k, _v] of Object.entries(value)) {
862
- if (sparse || _v != null) {
863
- out[_k] = this._write(mapMember, _v);
895
+ if (Array.isArray(value) && ns.isListSchema()) {
896
+ const listMember = ns.getValueSchema();
897
+ const out = [];
898
+ const sparse = !!ns.getMergedTraits().sparse;
899
+ for (const item of value) {
900
+ if (sparse || item != null) {
901
+ out.push(this._write(listMember, item));
902
+ }
864
903
  }
904
+ return out;
865
905
  }
866
- return out;
867
- }
868
- else if (ns.isStructSchema() && isObject) {
869
- const out = {};
870
- for (const [memberName, memberSchema] of serializingStructIterator(ns, value)) {
871
- const serializableValue = this._write(memberSchema, value[memberName], ns);
872
- if (serializableValue !== undefined) {
873
- const targetKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
874
- out[targetKey] = serializableValue;
906
+ if (ns.isMapSchema()) {
907
+ const mapMember = ns.getValueSchema();
908
+ const out = {};
909
+ const sparse = !!ns.getMergedTraits().sparse;
910
+ for (const [_k, _v] of Object.entries(value)) {
911
+ if (sparse || _v != null) {
912
+ out[_k] = this._write(mapMember, _v);
913
+ }
875
914
  }
915
+ return out;
876
916
  }
877
- return out;
878
- }
879
- if (value === null && container?.isStructSchema()) {
880
- return void 0;
881
- }
882
- if ((ns.isBlobSchema() && (value instanceof Uint8Array || typeof value === "string")) ||
883
- (ns.isDocumentSchema() && value instanceof Uint8Array)) {
884
- if (ns === this.rootSchema) {
885
- return value;
917
+ if (value instanceof Uint8Array && (ns.isBlobSchema() || ns.isDocumentSchema())) {
918
+ if (ns === this.rootSchema) {
919
+ return value;
920
+ }
921
+ return (this.serdeContext?.base64Encoder ?? utilBase64.toBase64)(value);
886
922
  }
887
- return (this.serdeContext?.base64Encoder ?? utilBase64.toBase64)(value);
888
- }
889
- if ((ns.isTimestampSchema() || ns.isDocumentSchema()) && value instanceof Date) {
890
- const format = protocols.determineTimestampFormat(ns, this.settings);
891
- switch (format) {
892
- case 5:
893
- return value.toISOString().replace(".000Z", "Z");
894
- case 6:
895
- return serde.dateToUtcString(value);
896
- case 7:
897
- return value.getTime() / 1000;
898
- default:
899
- console.warn("Missing timestamp format, using epoch seconds", value);
900
- return value.getTime() / 1000;
923
+ if (value instanceof Date && (ns.isTimestampSchema() || ns.isDocumentSchema())) {
924
+ const format = protocols.determineTimestampFormat(ns, this.settings);
925
+ switch (format) {
926
+ case 5:
927
+ return value.toISOString().replace(".000Z", "Z");
928
+ case 6:
929
+ return serde.dateToUtcString(value);
930
+ case 7:
931
+ return value.getTime() / 1000;
932
+ default:
933
+ console.warn("Missing timestamp format, using epoch seconds", value);
934
+ return value.getTime() / 1000;
935
+ }
901
936
  }
902
- }
903
- if (ns.isNumericSchema() && typeof value === "number") {
904
- if (Math.abs(value) === Infinity || isNaN(value)) {
905
- return String(value);
937
+ if (value instanceof serde.NumericValue) {
938
+ this.useReplacer = true;
906
939
  }
907
940
  }
941
+ if (value === null && container?.isStructSchema()) {
942
+ return void 0;
943
+ }
908
944
  if (ns.isStringSchema()) {
909
945
  if (typeof value === "undefined" && ns.isIdempotencyToken()) {
910
946
  return serde.generateIdempotencyToken();
@@ -916,12 +952,29 @@ class JsonShapeSerializer extends SerdeContextConfig {
916
952
  return serde.LazyJsonString.from(value);
917
953
  }
918
954
  }
955
+ return value;
956
+ }
957
+ if (typeof value === "number" && ns.isNumericSchema()) {
958
+ if (Math.abs(value) === Infinity || isNaN(value)) {
959
+ return String(value);
960
+ }
961
+ return value;
962
+ }
963
+ if (typeof value === "string" && ns.isBlobSchema()) {
964
+ if (ns === this.rootSchema) {
965
+ return value;
966
+ }
967
+ return (this.serdeContext?.base64Encoder ?? utilBase64.toBase64)(value);
968
+ }
969
+ if (typeof value === "bigint") {
970
+ this.useReplacer = true;
919
971
  }
920
972
  if (ns.isDocumentSchema()) {
921
973
  if (isObject) {
922
974
  const out = Array.isArray(value) ? [] : {};
923
975
  for (const [k, v] of Object.entries(value)) {
924
976
  if (v instanceof serde.NumericValue) {
977
+ this.useReplacer = true;
925
978
  out[k] = v;
926
979
  }
927
980
  else {
@@ -963,18 +1016,20 @@ class AwsJsonRpcProtocol extends protocols.RpcProtocol {
963
1016
  codec;
964
1017
  mixin;
965
1018
  awsQueryCompatible;
966
- constructor({ defaultNamespace, serviceTarget, awsQueryCompatible, }) {
1019
+ constructor({ defaultNamespace, serviceTarget, awsQueryCompatible, jsonCodec, }) {
967
1020
  super({
968
1021
  defaultNamespace,
969
1022
  });
970
1023
  this.serviceTarget = serviceTarget;
971
- this.codec = new JsonCodec({
972
- timestampFormat: {
973
- useTrait: true,
974
- default: 7,
975
- },
976
- jsonName: false,
977
- });
1024
+ this.codec =
1025
+ jsonCodec ??
1026
+ new JsonCodec({
1027
+ timestampFormat: {
1028
+ useTrait: true,
1029
+ default: 7,
1030
+ },
1031
+ jsonName: false,
1032
+ });
978
1033
  this.serializer = this.codec.createSerializer();
979
1034
  this.deserializer = this.codec.createDeserializer();
980
1035
  this.awsQueryCompatible = !!awsQueryCompatible;
@@ -1005,15 +1060,16 @@ class AwsJsonRpcProtocol extends protocols.RpcProtocol {
1005
1060
  this.mixin.setQueryCompatError(dataObject, response);
1006
1061
  }
1007
1062
  const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
1008
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
1063
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata, this.awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
1009
1064
  const ns = schema.NormalizedSchema.of(errorSchema);
1010
1065
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
1011
1066
  const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
1012
1067
  const exception = new ErrorCtor(message);
1013
1068
  const output = {};
1014
1069
  for (const [name, member] of ns.structIterator()) {
1015
- const target = member.getMergedTraits().jsonName ?? name;
1016
- output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
1070
+ if (dataObject[name] != null) {
1071
+ output[name] = this.codec.createDeserializer().readObject(member, dataObject[name]);
1072
+ }
1017
1073
  }
1018
1074
  if (this.awsQueryCompatible) {
1019
1075
  this.mixin.queryCompatOutput(dataObject, output);
@@ -1026,11 +1082,12 @@ class AwsJsonRpcProtocol extends protocols.RpcProtocol {
1026
1082
  }
1027
1083
 
1028
1084
  class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
1029
- constructor({ defaultNamespace, serviceTarget, awsQueryCompatible, }) {
1085
+ constructor({ defaultNamespace, serviceTarget, awsQueryCompatible, jsonCodec, }) {
1030
1086
  super({
1031
1087
  defaultNamespace,
1032
1088
  serviceTarget,
1033
1089
  awsQueryCompatible,
1090
+ jsonCodec,
1034
1091
  });
1035
1092
  }
1036
1093
  getShapeId() {
@@ -1045,11 +1102,12 @@ class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
1045
1102
  }
1046
1103
 
1047
1104
  class AwsJson1_1Protocol extends AwsJsonRpcProtocol {
1048
- constructor({ defaultNamespace, serviceTarget, awsQueryCompatible, }) {
1105
+ constructor({ defaultNamespace, serviceTarget, awsQueryCompatible, jsonCodec, }) {
1049
1106
  super({
1050
1107
  defaultNamespace,
1051
1108
  serviceTarget,
1052
1109
  awsQueryCompatible,
1110
+ jsonCodec,
1053
1111
  });
1054
1112
  }
1055
1113
  getShapeId() {
@@ -1531,18 +1589,13 @@ class AwsQueryProtocol extends protocols.RpcProtocol {
1531
1589
  Code: errorData.Code,
1532
1590
  Message: message,
1533
1591
  };
1534
- const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, (registry, errorName) => {
1535
- try {
1536
- return registry.getSchema(errorName);
1537
- }
1538
- catch (e) {
1539
- return registry.find((schema$1) => schema.NormalizedSchema.of(schema$1).getMergedTraits().awsQueryError?.[0] === errorName);
1540
- }
1541
- });
1592
+ const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
1542
1593
  const ns = schema.NormalizedSchema.of(errorSchema);
1543
1594
  const ErrorCtor = schema.TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
1544
1595
  const exception = new ErrorCtor(message);
1545
1596
  const output = {
1597
+ Type: errorData.Error.Type,
1598
+ Code: errorData.Error.Code,
1546
1599
  Error: errorData.Error,
1547
1600
  };
1548
1601
  for (const [name, member] of ns.structIterator()) {
@@ -1965,7 +2018,9 @@ class AwsRestXmlProtocol extends protocols.HttpBindingProtocol {
1965
2018
  }
1966
2019
  if (request.headers["content-type"] === this.getDefaultContentType()) {
1967
2020
  if (typeof request.body === "string") {
1968
- request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
2021
+ if (!request.body.startsWith("<?xml ")) {
2022
+ request.body = '<?xml version="1.0" encoding="UTF-8"?>' + request.body;
2023
+ }
1969
2024
  }
1970
2025
  }
1971
2026
  return request;