www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.net.curl: how to abort operation

I want to abort a download, if a condition inside of 
onReceiveHeader is true.
The following code do the job, but it feels very wrong - is there 
a better/proper way to do such a thing?

client.onReceiveHeader = (in char[] key, in char[] value) {
   if(key == "content-type") {
     if( -1 == value.indexOf("text" ,0, No.caseSensitive) ) {
       throw new ContentTypeException("No Text");
     }
   }
};
Apr 15 2017