Skip to content

Commit 5e5ab96

Browse files
committed
Added User-Agent header to httpFactory and Constants class to hold the sdk version.
1 parent 42ade47 commit 5e5ab96

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

examples/IBM.WatsonDeveloperCloud.Conversation.Example/Example.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public class Example
2323
{
2424
static void Main(string[] args)
2525
{
26-
string _username = "97a37439-9be0-4b01-8145-531c983dd34f";
27-
string _password = "SOuS08uQ8Z6v";
28-
string _workspaceID = "b42ee794-c019-4a0d-acd2-9e4d1d016767";
26+
string _username = "<username>";
27+
string _password = "<password>";
28+
string _workspaceID = "<workspace-id>";
2929

3030
ConversationServiceExample _conversationExample = new ConversationServiceExample(_username, _password, _workspaceID);
3131
Console.ReadKey();
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)