|
| 1 | +// <copyright file="NetworkRequestSentEventArgs.cs" company="WebDriver Committers"> |
| 2 | +// Licensed to the Software Freedom Conservancy (SFC) under one |
| 3 | +// or more contributor license agreements. See the NOTICE file |
| 4 | +// distributed with this work for additional information |
| 5 | +// regarding copyright ownership. The SFC licenses this file |
| 6 | +// to you under the Apache License, Version 2.0 (the "License"); |
| 7 | +// you may not use this file except in compliance with the License. |
| 8 | +// You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, software |
| 13 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// See the License for the specific language governing permissions and |
| 16 | +// limitations under the License. |
| 17 | +// </copyright> |
| 18 | + |
| 19 | +using System; |
| 20 | +using System.Collections.Generic; |
| 21 | + |
| 22 | +namespace OpenQA.Selenium |
| 23 | +{ |
| 24 | + /// <summary> |
| 25 | + /// Provides data for the NetworkRequestSent event of an object implementing the <see cref="INetwork"/> interface. |
| 26 | + /// </summary> |
| 27 | + public class NetworkRequestSentEventArgs : EventArgs |
| 28 | + { |
| 29 | + private readonly string requestId; |
| 30 | + private readonly string requestUrl; |
| 31 | + private readonly string requestMethod; |
| 32 | + private readonly string requestPostData; |
| 33 | + private readonly Dictionary<string, string> requestHeaders = new Dictionary<string, string>(); |
| 34 | + |
| 35 | + /// <summary> |
| 36 | + /// Initializes a new instance of the <see cref="NetworkRequestSentEventArgs"/> class. |
| 37 | + /// </summary> |
| 38 | + /// <param name="requestData">The <see cref="HttpRequestData"/> that describes the network request.</param> |
| 39 | + public NetworkRequestSentEventArgs(HttpRequestData requestData) |
| 40 | + { |
| 41 | + this.requestId = requestData.RequestId; |
| 42 | + this.requestUrl = requestData.Url; |
| 43 | + this.requestMethod = requestData.Method; |
| 44 | + this.requestPostData = requestData.PostData; |
| 45 | + foreach (KeyValuePair<string, string> header in requestData.Headers) |
| 46 | + { |
| 47 | + this.requestHeaders[header.Key] = header.Value; |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + /// <summary> |
| 52 | + /// Gets the internal request ID of the network request. |
| 53 | + /// </summary> |
| 54 | + public string RequestId => requestId; |
| 55 | + |
| 56 | + /// <summary> |
| 57 | + /// Gets the URL of the network request. |
| 58 | + /// </summary> |
| 59 | + public string RequestUrl => requestUrl; |
| 60 | + |
| 61 | + /// <summary> |
| 62 | + /// Gets the HTTP method of the network request. |
| 63 | + /// </summary> |
| 64 | + public string RequestMethod => requestMethod; |
| 65 | + |
| 66 | + /// <summary> |
| 67 | + /// Gets the post data of the network request, if any. |
| 68 | + /// </summary> |
| 69 | + public string RequestPostData => requestPostData; |
| 70 | + |
| 71 | + /// <summary> |
| 72 | + /// Gets the collection of headers associated with the network request. |
| 73 | + /// </summary> |
| 74 | + public IReadOnlyDictionary<string, string> RequestHeaders => requestHeaders; |
| 75 | + } |
| 76 | +} |
0 commit comments