docs: KB about modifying response with FiddlerCore
This commit is contained in:
Родитель
d7d8a91eba
Коммит
b509df65b1
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
title: Modifying a response with FiddlerCore
|
||||
description:
|
||||
type: how-to
|
||||
page_title: Modifying Response
|
||||
slug: modifying-response-fcore
|
||||
ticketid: 1516567
|
||||
res_type: kb
|
||||
---
|
||||
|
||||
#### Environment
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Product | FiddlerCore |
|
||||
| Product Version | 5.0.1 |
|
||||
|
||||
|
||||
#### Description
|
||||
|
||||
# Modifying a Response with FiddlerCore
|
||||
|
||||
To modify an HTTP response, ensure the session is set to **buffered mode**.
|
||||
|
||||
Use some of the early events of the response, for example, the `ResponseHeadersAvailable` to access the session object and set the `bBufferResponse` property to `true`. If the property is not set to `true`, in the `BeforeResponse` event, you'll receive a **copy** of the response, while it will be streamed to the client as well. So your modifications will not be applied to the response that the client will receive.
|
||||
|
||||
```CSharp
|
||||
private static void FiddlerApplication_ResponseHeadersAvailable(Session oSession)
|
||||
{
|
||||
|
||||
if (oSession.fullUrl.Contains("example.com"))
|
||||
{
|
||||
// Set this to true, so in BeforeResponse, you'll be able to modify the body.
|
||||
// If the value is false (default one), the response you'll work with within the BeforeResponse handler will be just a copy.
|
||||
// The original one will already be streamed to the client, and all of your modifications will not be visible there.
|
||||
oSession.bBufferResponse = true;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then you can handle the `BeforeResponse` event and modify the session's response as per your requirements.
|
||||
|
||||
```CSharp
|
||||
private static void FiddlerApplication_BeforeResponse(Session oSession)
|
||||
{
|
||||
if (oSession.fullUrl.Contains("example.com") && oSession.HTTPMethodIs("GET"))
|
||||
{
|
||||
oSession.bBufferResponse = true;
|
||||
oSession.utilDecodeResponse();
|
||||
|
||||
// Remove any compression or chunking
|
||||
oSession.utilDecodeResponse();
|
||||
var oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
|
||||
// Modify the body as you want
|
||||
oBody = "Replaced body";
|
||||
|
||||
// Set the response body to the div-less string
|
||||
oSession.utilSetResponseBody(oBody);
|
||||
}
|
||||
}
|
||||
```
|
|
@ -2,35 +2,32 @@
|
|||
title: Persisting the Root Certificate in Fiddler Core
|
||||
description: Article showing different methods for persisting the Certificate in Fiddler Core
|
||||
type: how-to
|
||||
page_title: Reusing Certificates in Fiddler Core
|
||||
page_title: Reusing Certificates
|
||||
slug: persisting-the-root-certificate-in-fiddler-core
|
||||
position:
|
||||
tags: Certificates, Bouncy Castle, MakeCert
|
||||
ticketid: 1429862
|
||||
res_type: kb
|
||||
---
|
||||
|
||||
## Environment
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Product Version</td>
|
||||
<td>4.6.20191.7809</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Product</td>
|
||||
<td>Progress® Telerik® FiddlerCore Embedded Engine</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Description
|
||||
#### Environment
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Product | Fiddler Core |
|
||||
| Product Version | 4.6.20191.7809 |
|
||||
|
||||
|
||||
#### Description
|
||||
|
||||
FiddlerCore uses different APIs for certificate creation than the Desktop Version. By default, FiddlerCore includes the CertMaker and BCMakeCert assemblies for use with the Bouncy Castle API but doesn't persist the certificate by default. The Bouncy Castle API is recommended because it can be used across multiple platforms.
|
||||
|
||||
## Suggested Workarounds
|
||||
|
||||
## Persisting and Reusing Certificates
|
||||
|
||||
Since FiddlerCore is a library that can be used in other applications, the API won't force persisting the Certificate and leaves the implementation up to the developer. The following workarounds are examples that show different ways this can be achieved.
|
||||
|
||||
### Using MakeCert.dll with Application (Recommended)
|
||||
## Using MakeCert.dll with Application (Recommended)
|
||||
|
||||
In this example, the MakeCert.dll is used with the ICertificateProvider5 Interface to store the Certificate Information. For example, call the `EnsureRootCertificate` method like below.
|
||||
|
||||
``` csharp
|
||||
|
@ -59,7 +56,8 @@ In this example, the MakeCert.dll is used with the ICertificateProvider5 Interfa
|
|||
}
|
||||
```
|
||||
|
||||
### Store Certificate Keys in Application Settings
|
||||
## Store Certificate Keys in Application Settings
|
||||
|
||||
This method was identified by Rick Strahl's blog post titled [Using FiddlerCore to Capture Http Requests with .NET](https://weblog.west-wind.com/posts/2014/jul/29/using-fiddlercore-to-capture-http-requests-with-net). The approach store the certificate and keys in the Application Configuration. See the below code snippet from Rick Strahl's blog post.
|
||||
|
||||
``` csharp
|
||||
|
|
Загрузка…
Ссылка в новой задаче