httpwebrequest - ETag not being returned by WebResponse Header in c# -
i trying extract etag response header. exist in response. can see using firebug , can see in response object using inspector:
status: 200 ok x-api-version: 1.3.2 access-control-allow-origin: * x-runtime: 0.151298 connection: keep-alive content-length: 8185 cache-control: public, max-age=11216 content-type: application/json; charset=utf-8 date: fri, 09 mar 2012 01:40:05 gmt expires: fri, 09 mar 2012 04:47:01 gmt etag: "bd3fe1123a8f55e01ca859f4804e8fbe" last-modified: fri, 09 mar 2012 00:47:01 gmt server: nginx/1.0.11
all other code working fine, making httpwebrequest, getting respose etc. problem null when trying etag (which existing in response header).
here simplified code:
var request = (httpwebrequest)webrequest.create(validuri); setheaders(); // helper function set basic headers. var response = request.getresponse(); var stream = response.getresponsestream(); var reader = new streamreader(stream); var result = reader.readtoend(); var etag = response.headers.get("etag");
anyone know why can't seem extract existing etag?
your code not reproduce problem describing. problem in have not mentioned. here short complete program based on code, executes , print out value of etag without problem:
using system; using system.io; using system.net; namespace so9628006 { class program { static void main() { var request = (httpwebrequest)webrequest.create("http://www.fiddler2.com/fiddler/fiddler.css"); var response = request.getresponse(); var stream = response.getresponsestream(); var reader = new streamreader(stream); var result = reader.readtoend(); var etag = response.headers.get("etag"); console.writeline(etag); } } }
output:
"6c3673ba919ec71:243"
could please provide short complete program illustrates issue?
Comments
Post a Comment