test(core/browser/platform): 26 extreme RED/GREEN TDD cycles and full regression hardening (3,235 PASS)
This commit is contained in:
parent
bcd242691f
commit
8677853822
100 changed files with 4814 additions and 333 deletions
|
|
@ -9,12 +9,15 @@ public sealed class MhtmlWebArchivePackager
|
|||
{
|
||||
public string Package(WebArchivePackageRequest request)
|
||||
{
|
||||
if (request == null)
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
|
||||
var boundary = "----=_NextPart_" + Guid.NewGuid().ToString("N");
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine("From: <Saved by PACA Browser>");
|
||||
sb.AppendLine($"Snapshot-Content-Location: {request.Url}");
|
||||
sb.AppendLine($"Subject: {request.Title}");
|
||||
sb.AppendLine($"Snapshot-Content-Location: {request.Url ?? string.Empty}");
|
||||
sb.AppendLine($"Subject: {request.Title ?? "Untitled"}");
|
||||
sb.AppendLine($"Date: {DateTime.UtcNow:R}");
|
||||
sb.AppendLine("MIME-Version: 1.0");
|
||||
sb.AppendLine($"Content-Type: multipart/related; boundary=\"{boundary}\"; type=\"text/html\"");
|
||||
|
|
@ -24,21 +27,26 @@ public sealed class MhtmlWebArchivePackager
|
|||
sb.AppendLine($"--{boundary}");
|
||||
sb.AppendLine("Content-Type: text/html; charset=\"utf-8\"");
|
||||
sb.AppendLine("Content-Transfer-Encoding: 8bit");
|
||||
sb.AppendLine($"Content-Location: {request.Url}");
|
||||
sb.AppendLine($"Content-Location: {request.Url ?? string.Empty}");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine(request.HtmlContent);
|
||||
sb.AppendLine(request.HtmlContent ?? string.Empty);
|
||||
sb.AppendLine();
|
||||
|
||||
// Resources
|
||||
foreach (var res in request.Resources)
|
||||
if (request.Resources != null)
|
||||
{
|
||||
sb.AppendLine($"--{boundary}");
|
||||
sb.AppendLine($"Content-Type: {res.MimeType}");
|
||||
sb.AppendLine("Content-Transfer-Encoding: base64");
|
||||
sb.AppendLine($"Content-Location: {res.Url}");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine(Convert.ToBase64String(res.Data));
|
||||
sb.AppendLine();
|
||||
foreach (var res in request.Resources)
|
||||
{
|
||||
if (res == null) continue;
|
||||
var data = res.Data ?? Array.Empty<byte>();
|
||||
sb.AppendLine($"--{boundary}");
|
||||
sb.AppendLine($"Content-Type: {res.MimeType ?? "application/octet-stream"}");
|
||||
sb.AppendLine("Content-Transfer-Encoding: base64");
|
||||
sb.AppendLine($"Content-Location: {res.Url ?? string.Empty}");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine(Convert.ToBase64String(data));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
sb.AppendLine($"--{boundary}--");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue