/// <summary> /// Create HTTP headers for a SOAP message. /// </summary> /// <param name="size">SOAP message size.</param> /// <param name="path">Address for the first line.</param> /// <param name="address">Hostname.</param> /// <param name="packet"></param> /// <param name="username"></param> /// <param name="password"></param> /// <param name="testingSettings"></param> /// <returns>UTF-8 encoded string.</returns> public static byte[] CreateHttpHeaders(long size, string path, string address, HttpPacket packet, string username, string password, DigestTestingSettings testingSettings, ref string nonceBack, ref int nonceCounter) { // Create HTTP headers and add content StringBuilder httpRequest = new StringBuilder(); httpRequest.AppendFormat(STATUSLINEPATTERN, path); httpRequest.AppendFormat(HOSTLINEPATTERN, address); httpRequest.AppendFormat("{0}: {1}; {2}={3}\r\n", CONTENTTYPE, APPLICATIONSOAPXML, CHARSET, "utf-8"); if (packet != null) { HttpDigest.DigestAuthenticationParameters parameters = new HttpDigest.DigestAuthenticationParameters(); parameters.Address = path; parameters.Challenge = packet; parameters.UserName = username; parameters.Password = password; httpRequest.AppendFormat("{0}\r\n", HttpDigest.CreateDigestAuthenticationHeader(parameters, testingSettings, ref nonceBack, ref nonceCounter)); } httpRequest.Append(CONTENTLENGTH + ": " + (size).ToString() + "\r\n"); httpRequest.Append("\r\n"); // Convert HTTP request to byte array to send return(Encoding.UTF8.GetBytes(httpRequest.ToString())); }
/// <summary> /// Create HTTP headers for a SOAP message. /// </summary> /// <param name="size">SOAP message size.</param> /// <param name="path">Address for the first line.</param> /// <param name="address">Hostname.</param> /// <returns>UTF-8 encoded string.</returns> public static byte[] CreateHttpHeaders(long size, string path, string address, HttpPacket packet, string username, string password) { // Create HTTP headers and add content StringBuilder httpRequest = new StringBuilder(); httpRequest.AppendFormat(STATUSLINEPATTERN, path); httpRequest.AppendFormat(HOSTLINEPATTERN, address); httpRequest.AppendFormat("{0}: {1}; {2}={3}\r\n", CONTENTTYPE, APPLICATIONSOAPXML, CHARSET, "utf-8"); if (packet != null) { httpRequest.AppendFormat("{0}\r\n", HttpDigest.CreateDigestAuthenticationHeader(packet, username, password, path)); } httpRequest.Append(CONTENTLENGTH + ": " + (size).ToString() + "\r\n"); httpRequest.Append("\r\n"); // Convert HTTP request to byte array to send return(Encoding.UTF8.GetBytes(httpRequest.ToString())); }