I have a, I hope, simple request.
I want to get a PDF from a response. But somehow I can't get the right response.
The MIME TYPE = "application/pdf", but when I try to get the PDF uit. I am never able to open the PDF.
It is from a HTTPS response but I do have the right certificate. Also, decode always returns false.
Could someone explain the right way to extract a file from a response?
PS: I use fiddlercore with C#
5 Answers, 1 is accepted
Generally speaking, you want to call oSession.utilDecodeResponse() on the session containing the desired traffic, then interact with the oSession.responseBodyBytes array of bytes.
Regards,
Eric Lawrence
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Then, when I detect the MIME = "application/pdf"
I call this event:
if
(oSession.oResponse.MIMEType ==
"application/pdf"
)
{
var isChecked = Task.Factory.StartNew(() => Fiddler.FiddlerApplication.AfterSessionComplete +=
delegate
(Session oS)
{
if
(oS.oResponse.MIMEType ==
"application/pdf"
)
{
oS.utilDecodeResponse();
SaveToOutput(oS.responseBodyBytes);
}
};
}
Move your code to the BeforeResponse handler instead.
Regards,
Eric Lawrence
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Then there is one more question.
Can I disable or cancel the file download dialog with Fiddlercore?
As I already extracted the file. I do not want to get the popup.
Fiddler/FiddlerCore don't have any awareness of your browser or its dialogs; they only see the traffic itself. In some cases, you could prevent the download dialog from appearing by (after you've already copied the responseBodyBytes wherever you wanted) replacing the HTTP response with an HTTP/204 "No content" reply, or a HTTP/200 reply with a simple HTML page indicating that the document was intercepted by an intermediary. (See the oSession.oRequest.FailSession method).
However, this may have unexpected behavior depending on how the target site attempted to kick off the file download. For instance, if it used the download attribute, the user would see a prompt to save your "no content" response.
Regards,
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.