简体   繁体   中英

How Do I Extract the Values from HTTP Response

I'm getting below response from web Request and I want to extract the data from the below string,can any one help me how I can do this.

message-headers[["Received", "by luna.mailgun.net with HTTP; Fri, 24 Apr 2015 04:49:58 +0000"], ["Mime-Version", "1.0"], ["Content-Type", ["text/html", {"charset": "ascii"}]], ["Subject", "Booking Confirmation :  2/99 Normanby Road, Kew,Australia"], ["From", "Digital Photography Inhouse <bookings@test.net.au>"], ["To", "manojkumar.soni@e-zest.in"], ["X-Mailgun-Track", "true"], ["X-Mailgun-Track-Clicks", "true"], ["X-Mailgun-Track-Opens", "true"], ["Message-Id", "<20150424044958.30315.17928@schedly.com.au>"], ["X-Mailgun-Sid", "WyIyZTY1OCIsICJtYW5vamt1bWFyLnNvbmlAZS16ZXN0LmluIiwgIjE4NmIzIl0="], ["Date", "Fri, 24 Apr 2015 04:49:58 +0000"], ["Sender", "bookings=manoj.net.au@test.com.au"], ["Content-Transfer-Encoding", ["quoted-printable", {}]]]

I'm reading the value like below please suggest me what is the best way to reading this data.

public int insertData(HttpRequest req)
{
    if (req["Parameter_Name"] != null)
        parameter_Name = (string)req["Parameter_Name"];

    if (req["message-headers"] != null)
    {
        message_headers = (string)req["message-headers"];    
    }     
}

You can ready the value of headers from HttpRequest as shown below.

IEnumerable<string> headerValues = req.Headers.GetValues("Parameter_Name");
var result = headerValues.FirstOrDefault();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM