angular - Angular 8:标头未在 HttpCliet.post 中正确发送
问题描述
以下代码有效:
this.http.post (TGT_IP,body, {responseType: 'arraybuffer'}).subscribe(
(val) => {
console.log("POST call successful value returned in body",
val);
},
response => {
console.log("POST call in error", response);
},
() => {
console.log("The POST observable is now completed.");
});
然后我尝试了以下代码:
var body = [0x11,0x22,0x33,0x44];
this.http.post (TGT_IP,
body,
{ headers: new HttpHeaders({'Content-Type': 'octet/stream',
'Accept': 'octet/stream'}),
responseType: 'arraybuffer'
}).subscribe(
(val) => {
console.log("POST call successful value returned in body",
val);
},
response => {
console.log("POST call in error", response);
},
() => {
console.log("The POST observable is now completed.");
});
你能告诉我为什么在这个代码正文中根本没有发送吗?
谢谢你,兹维卡
解决方案
推荐阅读
- spring - 应该设置什么状态来返回 HttpStatus 中实体的验证错误
- angular - Angular - 使用可编辑配置文件中的值为 serviceURL 定义 DI 令牌
- swift - 为什么在 SwiftUI 中单击空白区域后会调用 onTapGesture?
- arrays - 如何将直接值分配给 C 中动态创建的二维数组?
- java - 为什么在其父类中未定义子类构造函数?
- angular - 如何在结构指令中传递输入变量?
- google-apps-marketplace - 为现有用户重新发布APP的行为
- javascript - 如何将 hello 组件放在导航栏下?粒子占据整个屏幕
- arrays - 转义闭包在解码 JSON Swift 时捕获变异的“self”参数
- python-3.x - Pytorch BatchNorm3d / InstanceNorm3d 在数据大小 (1,C,1,1,1) 时不起作用