Skip to content

Commit bd5bbf5

Browse files
authored
Merge pull request #52 from atilatosta/gh-50-userAgent
Added User-Agent header to httpFactory and Constants class to hold th…
2 parents e100ea3 + 5e5ab96 commit bd5bbf5

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright 2017 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
namespace IBM.WatsonDeveloperCloud
19+
{
20+
/// <summary>
21+
/// This class holds constant values for the SDK.
22+
/// </summary>
23+
public class Constants
24+
{
25+
/// <summary>
26+
/// The version number for this SDK build. Added to the header in
27+
/// each request as `User-Agent`.
28+
/// </summary>
29+
public const string SDK_VERSION = "0.0.1-alpha";
30+
}
31+
}

src/IBM.WatsonDeveloperCloud/Http/HttpFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public static HttpRequestMessage GetRequestMessage(HttpMethod method, Uri resour
4545

4646
// add default headers
4747
request.Headers.Add("accept", formatters.SelectMany(p => p.SupportedMediaTypes).Select(p => p.MediaType));
48+
request.Headers.Add("User-Agent", Constants.SDK_VERSION);
4849

4950
return request;
5051
}

0 commit comments

Comments
 (0)