@@ -166,7 +166,8 @@ function TDPMServerPackageRepository.DownloadPackage(const cancellationToken : I
166166 httpClient := THttpClientFactory.CreateClient(uri.BaseUriString);
167167
168168 request := httpClient.CreateRequest(path)
169- .WithHeader(cUserAgentHeader,cDPMUserAgent);
169+ .WithHeader(cClientVersionHeader,cDPMClientVersion)
170+ .WithHeader(cUserAgentHeader,cDPMUserAgent);
170171
171172 ForceDirectories(localFolder);
172173 destFile := IncludeTrailingPathDelimiter(localFolder) + packageIdentity.ToString + cPackageFileExt;
@@ -224,11 +225,13 @@ function TDPMServerPackageRepository.FindLatestVersion(const cancellationToken:
224225 httpClient := THttpClientFactory.CreateClient(uri.BaseUriString);
225226
226227 request := httpClient.CreateRequest(uri.AbsolutePath)
227- .WithHeader(cUserAgentHeader,cDPMUserAgent)
228- .WithAccept(' application/json' )
229- .WithParameter(' id' , id)
230- .WithParameter(' compiler' , CompilerToString(compilerVersion))
231- .WithParameter(' platform' , DPMPlatformToString(platform));
228+ .WithHeader(cUserAgentHeader,cDPMUserAgent)
229+ .WithHeader(cClientVersionHeader,cDPMClientVersion)
230+ .WithAccept(' application/json' )
231+ .WithParameter(' id' , id)
232+ .WithParameter(' compiler' , CompilerToString(compilerVersion))
233+ .WithParameter(' platform' , DPMPlatformToString(platform));
234+
232235 // this looks odd but if we specify a version then we want that version only!
233236 if not version.IsEmpty then
234237 request.WithParameter(' version' , version.ToStringNoMeta)
@@ -314,8 +317,9 @@ function TDPMServerPackageRepository.GetPackageFeed(const cancellationToken : IC
314317 httpClient := THttpClientFactory.CreateClient(uri.BaseUriString);
315318
316319 request := httpClient.CreateRequest(uri.AbsolutePath)
317- .WithHeader(cUserAgentHeader,cDPMUserAgent)
318- .WithAccept(' application/json' );
320+ .WithHeader(cUserAgentHeader,cDPMUserAgent)
321+ .WithHeader(cClientVersionHeader,cDPMClientVersion)
322+ .WithAccept(' application/json' );
319323
320324 if options.SearchTerms <> ' ' then
321325 request.WithParameter(' q' , Trim(options.SearchTerms));
@@ -437,9 +441,10 @@ function TDPMServerPackageRepository.GetPackageFeedByIds(const cancellationToken
437441 end ;
438442
439443 request := httpClient.CreateRequest(uri.AbsolutePath)
440- .WithHeader(cUserAgentHeader,cDPMUserAgent)
441- .WithBody(sBody, TEncoding.UTF8)
442- .WithContentType(' application/json' , ' utf-8' );
444+ .WithHeader(cUserAgentHeader,cDPMUserAgent)
445+ .WithHeader(cClientVersionHeader,cDPMClientVersion)
446+ .WithBody(sBody, TEncoding.UTF8)
447+ .WithContentType(' application/json' , ' utf-8' );
443448
444449 try
445450 Logger.Information(' POST ' + uri.ToString);
@@ -527,6 +532,7 @@ function TDPMServerPackageRepository.GetPackageIcon(const cancelToken : ICancell
527532 httpClient := THttpClientFactory.CreateClient(uri.BaseUriString);
528533
529534 request := httpClient.CreateRequest(path)
535+ .WithHeader(cClientVersionHeader,cDPMClientVersion)
530536 .WithHeader(cUserAgentHeader,cDPMUserAgent);
531537 try
532538 response := request.Get(cancelToken);
@@ -600,8 +606,10 @@ function TDPMServerPackageRepository.GetPackageInfo(const cancellationToken : IC
600606 httpClient := THttpClientFactory.CreateClient(uri.BaseUriString);
601607
602608 request := httpClient.CreateRequest(path)
603- .WithHeader(cUserAgentHeader,cDPMUserAgent)
604- .WithHeader(cAcceptHeader, ' application/json' );
609+ .WithHeader(cUserAgentHeader,cDPMUserAgent)
610+ .WithHeader(cClientVersionHeader,cDPMClientVersion)
611+ .WithHeader(cAcceptHeader, ' application/json' );
612+
605613 try
606614 Logger.Information(' GET ' + uri.BaseUriString + path);
607615 response := request.Get(cancellationToken);
@@ -687,7 +695,9 @@ function TDPMServerPackageRepository.GetPackageMetaData(const cancellationToken:
687695 httpClient := THttpClientFactory.CreateClient(uri.BaseUriString);
688696
689697 request := httpClient.CreateRequest(path)
690- .WithHeader(cUserAgentHeader,cDPMUserAgent);
698+ .WithHeader(cUserAgentHeader,cDPMUserAgent)
699+ .WithHeader(cClientVersionHeader,cDPMClientVersion);
700+
691701 Logger.Information(' GET ' + uri.BaseUriString + path);
692702
693703 try
@@ -763,6 +773,7 @@ function TDPMServerPackageRepository.GetPackageVersions(const cancellationToken
763773
764774 request := httpClient.CreateRequest(path)
765775 .WithHeader(cUserAgentHeader,cDPMUserAgent)
776+ .WithHeader(cClientVersionHeader,cDPMClientVersion)
766777 .WithParameter(cPreReleaseParam, Lowercase(BoolToStr(preRelease, true)));
767778
768779 try
@@ -844,11 +855,13 @@ function TDPMServerPackageRepository.GetPackageVersionsWithDependencies(const ca
844855 httpClient := THttpClientFactory.CreateClient(uri.BaseUriString);
845856
846857 request := httpClient.CreateRequest(path)
847- .WithHeader(cUserAgentHeader,cDPMUserAgent)
848- .WithAccept(' application/json' )
849- // parameters can't have spaces.. winhttp will report invalid header!
850- .WithParameter(' versionRange' , StringReplace(versionRange.ToString, ' ' , ' ' , [rfReplaceAll]))
851- .WithParameter(' prerel' , Lowercase(BoolToStr(preRelease, true)));
858+ .WithHeader(cUserAgentHeader,cDPMUserAgent)
859+ .WithHeader(cClientVersionHeader,cDPMClientVersion)
860+ .WithAccept(' application/json' )
861+ // parameters can't have spaces.. winhttp will report invalid header!
862+ .WithParameter(' versionRange' , StringReplace(versionRange.ToString, ' ' , ' ' , [rfReplaceAll]))
863+ .WithParameter(' prerel' , Lowercase(BoolToStr(preRelease, true)));
864+
852865 stopwatch := TStopwatch.StartNew;
853866 try
854867 Logger.Information(' GET ' + uri.BaseUriString + path);
@@ -915,7 +928,10 @@ function TDPMServerPackageRepository.GetServiceIndex(const cancellationToken: IC
915928
916929 httpClient := THttpClientFactory.CreateClient(uri.BaseUriString);
917930 request := httpClient.CreateRequest(uri.AbsolutePath)
918- .WithHeader(cUserAgentHeader,cDPMUserAgent).WithAccept(' application/json' );
931+ .WithHeader(cClientVersionHeader,cDPMClientVersion)
932+ .WithHeader(cUserAgentHeader,cDPMUserAgent)
933+ .WithAccept(' application/json' );
934+
919935 try
920936// Logger.Debug('getting service Index ' + self.SourceUri);
921937 response := request.Get(cancellationToken);
@@ -976,8 +992,9 @@ function TDPMServerPackageRepository.List(const cancellationToken : ICancellatio
976992 httpClient := THttpClientFactory.CreateClient(uri.BaseUriString);
977993
978994 request := httpClient.CreateRequest(uri.AbsolutePath)
979- .WithHeader(cUserAgentHeader,cDPMUserAgent)
980- .WithAccept(' application/json' );
995+ .WithHeader(cUserAgentHeader,cDPMUserAgent)
996+ .WithHeader(cClientVersionHeader,cDPMClientVersion)
997+ .WithAccept(' application/json' );
981998
982999 if options.SearchTerms <> ' ' then
9831000 request.WithParameter(' q' , options.SearchTerms);
@@ -1089,11 +1106,10 @@ function TDPMServerPackageRepository.Push(const cancellationToken : ICancellatio
10891106 // todo: Add BaseUri to Uri class
10901107 httpClient := THttpClientFactory.CreateClient(uri.BaseUriString);
10911108 request := httpClient.CreateRequest(uri.AbsolutePath)
1092- .WithHeader(cUserAgentHeader,cDPMUserAgent);
1093-
1094- request.WithHeader(' X-ApiKey' , pushOptions.ApiKey);
1095-
1096- request.WithFile(pushOptions.PackagePath);
1109+ .WithHeader(cUserAgentHeader,cDPMUserAgent)
1110+ .WithHeader(cClientVersionHeader,cDPMClientVersion)
1111+ .WithHeader(' X-ApiKey' , pushOptions.ApiKey)
1112+ .WithFile(pushOptions.PackagePath);
10971113
10981114 response := request.Put(cancellationToken);
10991115
0 commit comments