Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
45fd04f6
R
runtime
项目概览
dotNET Platform
/
runtime
10 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
45fd04f6
编写于
2月 28, 2023
作者:
P
Pavel Savara
提交者:
GitHub
2月 28, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test retry logic (#82722)
上级
cd66437f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
47 addition
and
2 deletion
+47
-2
src/mono/sample/wasm/browser-advanced/Wasm.Advanced.Sample.csproj
.../sample/wasm/browser-advanced/Wasm.Advanced.Sample.csproj
+3
-0
src/mono/sample/wasm/browser-advanced/main.js
src/mono/sample/wasm/browser-advanced/main.js
+18
-0
src/mono/sample/wasm/simple-server/Program.cs
src/mono/sample/wasm/simple-server/Program.cs
+26
-2
未找到文件。
src/mono/sample/wasm/browser-advanced/Wasm.Advanced.Sample.csproj
浏览文件 @
45fd04f6
...
...
@@ -17,4 +17,7 @@
<NativeFileReference Include="fibonacci.c" />
<TrimmerRootDescriptor Include="$(MSBuildThisFileDirectory)ILLink.Descriptors.xml" />
</ItemGroup>
<Target Name="RunSample" DependsOnTargets="RunSampleWithBrowserAndSimpleServer" />
</Project>
src/mono/sample/wasm/browser-advanced/main.js
浏览文件 @
45fd04f6
...
...
@@ -7,6 +7,9 @@ function add(a, b) {
return
a
+
b
;
}
let
testAbort
=
true
;
let
testError
=
true
;
try
{
const
{
runtimeBuildInfo
,
setModuleImports
,
getAssemblyExports
,
runMain
,
getConfig
,
Module
}
=
await
dotnet
.
withElementOnExit
()
...
...
@@ -22,6 +25,21 @@ try {
config
.
environmentVariables
[
"
MONO_LOG_LEVEL
"
]
=
"
debug
"
;
config
.
browserProfilerOptions
=
{};
},
imports
:
{
fetch
:
(
url
,
fetchArgs
)
=>
{
console
.
log
(
"
fetching
"
+
url
);
// we are testing that we can retry loading of the assembly
if
(
testAbort
&&
url
.
indexOf
(
'
System.Private.Uri.dll
'
)
!=
-
1
)
{
testAbort
=
false
;
return
fetch
(
url
+
"
?testAbort=true
"
,
fetchArgs
);
}
if
(
testError
&&
url
.
indexOf
(
'
System.Console.dll
'
)
!=
-
1
)
{
testError
=
false
;
return
fetch
(
url
+
"
?testError=true
"
,
fetchArgs
);
}
return
fetch
(
url
,
fetchArgs
);
}
},
preInit
:
()
=>
{
console
.
log
(
'
user code Module.preInit
'
);
},
preRun
:
()
=>
{
console
.
log
(
'
user code Module.preRun
'
);
},
onRuntimeInitialized
:
()
=>
{
...
...
src/mono/sample/wasm/simple-server/Program.cs
浏览文件 @
45fd04f6
...
...
@@ -156,19 +156,43 @@ private async void ServeAsync(HttpListenerContext context)
string
?
contentType
=
null
;
if
(
path
.
EndsWith
(
".wasm"
))
contentType
=
"application/wasm"
;
if
(
path
.
EndsWith
(
".webcil"
))
if
(
path
.
EndsWith
(
".webcil"
)
||
path
.
EndsWith
(
".dll"
)
||
path
.
EndsWith
(
".pdb"
)
)
contentType
=
"application/octet-stream"
;
if
(
path
.
EndsWith
(
".json"
))
contentType
=
"application/json"
;
if
(
path
.
EndsWith
(
".js"
)
||
path
.
EndsWith
(
".mjs"
)
||
path
.
EndsWith
(
".cjs"
))
contentType
=
"text/javascript"
;
var
stream
=
context
.
Response
.
OutputStream
;
// test download re-try
if
(
url
.
Query
.
Contains
(
"testError"
))
{
Console
.
WriteLine
(
"Faking 500 "
+
url
);
context
.
Response
.
StatusCode
=
(
int
)
HttpStatusCode
.
InternalServerError
;
await
stream
.
WriteAsync
(
buffer
,
0
,
0
).
ConfigureAwait
(
false
);
await
stream
.
FlushAsync
();
context
.
Response
.
Close
();
return
;
}
if
(
contentType
!=
null
)
context
.
Response
.
ContentType
=
contentType
;
context
.
Response
.
ContentLength64
=
buffer
.
Length
;
context
.
Response
.
AppendHeader
(
"cache-control"
,
"public, max-age=31536000"
);
var
stream
=
context
.
Response
.
OutputStream
;
// test download re-try
if
(
url
.
Query
.
Contains
(
"testAbort"
))
{
Console
.
WriteLine
(
"Faking abort "
+
url
);
await
stream
.
WriteAsync
(
buffer
,
0
,
10
).
ConfigureAwait
(
false
);
await
stream
.
FlushAsync
();
await
Task
.
Delay
(
100
);
context
.
Response
.
Abort
();
return
;
}
try
{
await
stream
.
WriteAsync
(
buffer
).
ConfigureAwait
(
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录