/* * Copyright 2012 Splunk, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"): you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ namespace Splunk { using System; using System.Collections.Generic; /// /// The request Message is an abstraction of the HTTP/S web request message /// public class RequestMessage { /// /// The method, defaults to get. /// private string method = "GET"; // "GET" | "PUT" | "POST" | "DELETE" /// /// The header /// private Dictionary header = null; /// /// The content /// private object content = null; /// /// Initializes a new instance of the /// class. /// public RequestMessage() { } /// /// Initializes a new instance of the /// class, /// with specific method. /// /// The method public RequestMessage(string method) { this.method = method; } /// /// Gets the header dictionary. /// /// The header public Dictionary Header { get { if (this.header == null) { this.header = new Dictionary(); } return this.header; } } /// /// Gets or sets the HTTP/S method. /// /// The method public string Method { get { return this.method; } set { value = value.ToUpper(); if (!this.CheckMethod(value)) { throw new Exception("Bad HTTP method"); } this.method = value; } } /// /// Gets or sets the content. /// /// The content public object Content { get { return this.content; } set { this.content = value; } } /// /// Checks if the method is supported. /// /// The method name /// Whether or not the method is supported private bool CheckMethod(string value) { return value.Equals("GET") || value.Equals("PUT") || value.Equals("POST") || value.Equals("DELETE"); } } }