c# - Server returns 421 HTTP error when Fiddler is not running -


i'm building api pixiv , far i've managed complete login process , searching tags works well.

now want download image on selected webpage. @ first getting certificate errors. fixed temporarily ignoring certificate validation.

then interesting thing happened... if fiddler running in background - response received , able download image. no problems, whatsoever.

but when fiddler not running, remote server returned 421 error code.

things i've tried:

  • closing every response manually , using "using" statement
  • enforced keep-alive header.
  • explicitly declared use of http/1.1
  • changing proxy settings on httpwebrequest object

my image request code looks this:

httpwebrequest imagerequest = (httpwebrequest)webrequest.create(imglink); imagerequest.host = $"i.pximg.net"; imagerequest.useragent = user_agent; imagerequest.accept = "image/webp,image/*,*/*;q=0.8"; imagerequest.referer = post.postlink; imagerequest.headers.add("accept-encoding", "gzip, deflate, sdch, br"); imagerequest.headers.add("accept-language", "en-us,en;q=0.8,sl;q=0.6");  byte[] imagecontent; using (var imageresponse = (httpwebresponse)imagerequest.getresponse()) {     using (var imagestream = imageresponse.getresponsestream())     {         imagecontent = imagestream.readstream();     } } 

(i send request before 1 in order image link)

example of "imglink":

https://i3.pixiv.net/img-original/img/2014/02/09/00/10/03/41485846_p0.jpg

fiddler displays sent request this:

get https://i.pximg.net/img-original/img/2014/02/09/00/10/03/41485846_p0.jpg   http/1.1 user-agent: mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml,   gecko) chrome/54.0.2840.99 safari/537.36 accept: image/webp,image/*,*/*;q=0.8 referer: http://www.pixiv.net/whitecube/user/2824699/illust/41485846 accept-encoding: gzip, deflate, sdch, br accept-language: en-us,en;q=0.8,sl;q=0.6 host: i.pximg.net 

fiddler not show signs of http protocol violations.

seems blind. "imglink" had wrong hostname set entire time, didn't notice because hostnames similar. guess fiddler automatically fixing me...

next time sure triple-check hostname. for help.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -