Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Fiddler">
<HintPath>..\..\..\Users\bdrupieski\AppData\Local\Programs\Fiddler\Fiddler.exe</HintPath>
<HintPath>..\packages\Fiddler.exe</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand All @@ -58,7 +58,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(TargetPath)" "%25userprofile%25\My Documents\Fiddler2\ImportExport\$(TargetFilename)"
copy "Newtonsoft.Json.dll" "%25userprofile%25\My Documents\Fiddler2\ImportExport\Newtonsoft.Json.dll"</PostBuildEvent>
<PostBuildEvent>copy "$(TargetPath)" "%25userprofile%25\AppData\Local\Programs\Fiddler\ImportExport\$(TargetFilename)"
copy "Newtonsoft.Json.dll" "%25userprofile%25\AppData\Local\Programs\Fiddler\ImportExport\Newtonsoft.Json.dll"</PostBuildEvent>
</PropertyGroup>
</Project>
12 changes: 11 additions & 1 deletion ExportSessionsToPostmanCollection/PostmanCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class PostmanItem
{
public string Name { get; set; }
public PostmanRequest Request { get; set; }
public PostmanResponse Response { get; set; }
public List<PostmanResponse> Response { get; set; }
}

public class PostmanRequest
Expand All @@ -45,8 +45,17 @@ public class PostmanBody
{
public string Mode { get; set; }
public string Raw { get; set; }
public PostmanRequestOptions Options { get; set; }
}
public class PostmanRequestOptions
{
public PostmanRequestOptionsRow Row { get; set; }

}
public class PostmanRequestOptionsRow
{
public string Language { get; set; }
}
public class PostmanRequestAuth
{
public string Type { get; set; }
Expand All @@ -62,6 +71,7 @@ public class PostmanResponse
public List<PostmanListItem> Header { get; set; }
public List<PostmanListItem> Cookie { get; set; }
public string Body { get; set; }
public string _postman_previewlanguage { get; set; }
}

public class PostmanListItem
Expand Down
31 changes: 22 additions & 9 deletions ExportSessionsToPostmanCollection/PostmanSessionExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool ReportProgress(float percentage, string message)

if (oSessions.Length > 100)
{
var confirmResult = MessageBox.Show($"You're about to export {oSessions.Length} sessions. That's a lot. Are you sure you want to do that?",
var confirmResult = MessageBox.Show($"You're about to export {oSessions.Length} sessions. That's a lot. Are you sure you want to do that?",
"Just Checking", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

if (confirmResult != DialogResult.Yes)
Expand Down Expand Up @@ -86,20 +86,33 @@ bool ReportProgress(float percentage, string message)
{
Mode = "raw",
Raw = session.GetRequestBodyAsString(),
Options = new PostmanRequestOptions
{
Row = new PostmanRequestOptionsRow
{
Language = "json",
}
}
},
},
Response = new PostmanResponse
{
Code = session.responseCode,
Name = session.PathAndQuery,
Body = session.GetResponseBodyAsString(),
Status = session.ResponseHeaders.StatusDescription,
Header = new List<PostmanListItem>(session.ResponseHeaders.Count() + 1),
Response = new List<PostmanResponse>(){
new PostmanResponse
{
Code = session.responseCode,
Name = session.PathAndQuery,
Body = session.GetResponseBodyAsString(),
Status = session.ResponseHeaders.StatusDescription,
Header = new List<PostmanListItem>(session.ResponseHeaders.Count() + 1),
_postman_previewlanguage = "json",
}
},
};

postmanItem.Response[0].OriginalRequest = postmanItem.Request;

foreach (var requestHeader in session.RequestHeaders)
{
if (requestHeader.Name == "Host") continue;
postmanItem.Request.Header.Add(new PostmanListItem
{
Type = "text",
Expand All @@ -110,7 +123,7 @@ bool ReportProgress(float percentage, string message)

foreach (var responseHeader in session.ResponseHeaders)
{
postmanItem.Response.Header.Add(new PostmanListItem
postmanItem.Response[0].Header.Add(new PostmanListItem
{
Key = responseHeader.Name,
Value = responseHeader.Value
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 20220421

修复 reponse,并将类型改为 json。

# FiddlerExportToPostman

This is a Fiddler extension for exporting sessions into a format that can be imported by Postman.
Expand Down