我想弄清楚如何在VBA中进行POST.理想情况下,我正在寻找一个可以玩的简单工作示例.这是我到目前为止所做的,但我不确定该如何处理它.大多数形式数据是什么样的.
Function WinHTTPPostRequest(URL, formdata, Boundary)
Dim http
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "POST", URL, False
'Set Content-Type header'
http.setRequestHeader "Content-Type", "multipart/form-data; boundary=" + Boundary
'Send the form data To URL As POST binary request'
http.send formdata
'Get a result of the script which has received upload'
WinHTTPPostRequest = http.responseText
End Function
Run Code Online (Sandbox Code Playgroud)
编辑:
所以我安装了firebug,以便我可以获得"formdata"的对象名称(参见代码).我原以为formdata看起来像这样的"Form1 = A&Form2 = B".但它还没有成功.关于我应该如何做得更好的任何建议?
编辑:所以似乎可能有我需要在POST请求中发送的隐藏字段.
我使用C#在.net 2.0应用程序中实现了异步可插拔协议,它将存储在本地机器上的html文件加载到MemoryStream中.
当我使用本地文件路径在webbrowser控件中正常加载html文件时,xmlhttprequest工作正常但通过协议加载文件并尝试使用xmlhttprequest返回拒绝访问错误.
我认为这种行为是由于webbrowser控件不再知道html文件存储在本地计算机上,并将它们加载到不受信任的Internet区域.
即使我在IInternetSecurityManager的ProcessUrlAction中为URLACTION_CROSS_DOMAIN_DATA返回S_OK,我用断点检查它以确保它被触发,我的IInternetSecurityManager的返回值被忽略.
我已经尝试将pdwZone设置为IInternetSecurityManager的MapUrlToZone中的tagURLZONE.URLZONE_LOCAL_MACHINE以获取我的协议URL,并使用GetSecurityId稍微玩了一下,虽然我不确定我正在做什么并打破其他事情,如允许脚本加载等...似乎没有什么能够允许跨域xmlhttprequest.
任何人都知道如何让这个工作.
我对 XMLHttpRequests 比较陌生,因为我以前使用过 jQuery 的 AjAX 方法。但是我需要在网络工作者中工作,现在我必须使用经典的 XMLHttpRequest 来解决性能问题。
我正在尝试cache从 jquery重建-property。如果缓存应该被禁用,我添加这个:
xhr.setRequestHeader("Cache-Control", "no-cache");
Run Code Online (Sandbox Code Playgroud)
但是如果我想强制缓存(而不是阻止),我应该设置什么标头?
每个开发流程都有两个部分.首先要努力工作并开发应用程序.SECOND努力工作并使其与傲慢的IE相媲美.
我们有一个AngularJS (v1.3.13)没有开发任何服务器端代码的应用程序Webstorm.我们正在REST打电话给服务.我们的应用程序适用于Chrome和Firefox,没有任何控制台错误.但是,当我们尝试在IE11或IE9(未尝试IE10)中打开页面时,我们的页面无法加载.控制台建议我们有2个错误.其中一个正在Access is Denied开启
xhr.open(method, url, true);
Run Code Online (Sandbox Code Playgroud)
在angular.js.
互联网上有很多帖子,似乎都没有.这就是我尝试过的.
IIS使用已更改的Handler Mappings 托管应用程序以支持应用程序池上的跨域调用.Net v4.0(如高级建议)JSONP并尝试向标头添加Access-Control-Allow-Origin(值为*).错误仍在追逐着我们.甚至我的同事也在他们的机器上尝试过相同的打击.有没有人建议我这件事.
它可能是CORS,我可能需要去xdr(XDomainRequest),但不知道如何使用它,因为error.js中的错误.我当然不是这方面的专家所以请建议.
错误的屏幕截图:

IE显示另一个错误:
[$injector:nomod] Module 'ngLocale' is not available!
You either misspelled the module name or forgot to load it.
If registering a module ensure that you specify the dependencies
as the second argument.
http://errors.angularjs.org/1.2.16/$injector/nomod?p0=ngLocale我现在忽略了.
请给我一些建议.谢谢.
我需要通过 GET 调用访问数据,但资源受单点登录保护。我有 URI 端点和单点登录凭据。我开始使用 XMLHttpRequest() 发出 ajax 请求,但得到了这个:
被 CORS 策略阻止:请求的资源上不存在“Access-Control-Allow-Origin”标头。
由于我无权访问服务器,因此无法将“Access-Control-Allow-Origin”设置为 true,因此我决定转而使用带有 Flask 后端的 Python 请求库进行调用。我尝试将用户凭据与 GET 请求一起传递,如下所示:
headers = {'accept': 'application/json;odata=verbose'}
r = requests.get(url, auth=HTTPBasicAuth(userid, password), headers=headers)
print r.status_code #prints 403
print r.content #prints 403 forbidden
Run Code Online (Sandbox Code Playgroud)
有没有办法访问这样的资源?请注意,SSO 是使用 SAML 2.0 配置的
更新: 跟踪 giaco 建议的链接后,我现在可以以编程方式登录到 SSO。至少,我认为是这样..(s.post(..) 返回的 HTML 实际上仍然有 403 禁止代码——但是当我在浏览器中点击 url 时,它重定向到登录页面)但是,当我发送 GET请求,我再次收到 403 FORBIDDEN 消息。以下是更新后的代码:
payload = {
'UserName': username,
'Password': password
}
print "configured payload" #successfully printed on console
with requests.Session() as s:
p …Run Code Online (Sandbox Code Playgroud) I need to download a large file with JavaScript using XMLHttpRequest or fetch without saving the file first in the RAM-Memory.
Normal link download doesn't work for me, because I need to send a Bearer Token in the header of the request.
我可以设法下载一个文件,但是这个“解决方案”,它首先将文件保存在 RAM 内存中,然后再出现保存对话框,这样如果文件大于可用的 RAM 内存,浏览器就会刹车。
这是我使用 fetch 的“解决方案”:
var myHeaders = new Headers();
myHeaders.append('Authorization', `Bearer ${token}`);
var myInit = { method: 'GET',
headers: myHeaders,
mode: 'cors',
cache: 'default' };
var a = document.createElement('a');
fetch(url,myInit)
.then((response)=> {
return response.blob(); …Run Code Online (Sandbox Code Playgroud) 我遇到了一个非常奇怪的问题.我们正在将一个应用程序投入生产,其中一个POST请求变为POST,然后直接向同一URL发送GET请求,后端(Laravel)永远不会收到POST.在Chrome网络选项卡中,它看起来只是一个GET,但是使用Burpsuite,我们可以看到POST请求.
代码负责
async store() {
// This prints post
console.log(this.method());
await this.form[this.method()]('/api/admin/users/' + (this.isUpdate() ? this.id : ''));
if (!this.isUpdate()) {
this.form.reset();
}
},
Run Code Online (Sandbox Code Playgroud)
form.post方法的内容
return new Promise((resolve, reject) => {
axios[requestType](url, this.data())
.then(response => {
this.busy = false;
this.onSuccess(response.data);
resolve(response.data);
})
.catch(error => {
this.busy = false;
if (error.response.status == 400) {
return this.displayErrors(error.response.data)
}
this.onFail(error.response.data.errors);
reject(error.response.data);
});
});
Run Code Online (Sandbox Code Playgroud) 我正在开发一个用 javascript 编写的项目。我可以看到,对于请求,已经创建了 XMLHttpRequest 对象。
它对“http”请求工作正常,但对“https”请求失败。由于我在开发环境中调试它,我只想知道如何忽略XmlHttpRequest对象中的自签名证书?
在搜索时我发现了这个,
httpreq = new ActiveXObject("Msxml2.ServerXMLHTTP.3.0");
httpreq.setOption(2, 13056);
Run Code Online (Sandbox Code Playgroud)
但答案不适用于现代浏览器,如 Microsoft edge、chorme...
我也发现了这个,它清楚地表明 setOption() 可用于忽略 ssl 证书。
我在代码中可以看到的一个区别是我使用以下命令创建了 httpreq:
httpreq = new xmlhttprequest();//This is for chorme and Firefox
Run Code Online (Sandbox Code Playgroud)
那么有什么方法可以忽略 XmlHttpRequest 中的自签名证书吗?
我正在尝试将视频文件从 JS 上传到 S3 存储桶,但现在收到 400 错误请求。我确信我已经正确设置了一切,但我可以做一些事情。
我在服务器上生成一个 URL,如下所示:
const client = new S3({
accessKeyId: 'id-ommited',
secretAccessKey: 'key-ommited',
region: 'eu-west-2',
useAccelerateEndpoint: true
});
const url = client.getSignedUrl('putObject', {
Bucket: 'screen-capture-uploads',
Key: 'video.webm',
Expires: 60 * 60,
ContentType: 'application/octet-stream'
});
Run Code Online (Sandbox Code Playgroud)
这个 URL 在我的前端似乎没问题,我将它传递给 XMLHttpRequest,如下所示
const xhr = new XMLHttpRequest();
xhr.open('PUT', body.url); // body.url being the presigned url
xhr.setRequestHeader('x-amz-acl', 'public-read');
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
xhr.send(blob); // blob being the webm binary
Run Code Online (Sandbox Code Playgroud)
我正在使用 CORS 设置,只允许从任何地方进行 PUT
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedHeader>*</AllowedHeader> …Run Code Online (Sandbox Code Playgroud) 我需要在我的 Chrome 扩展程序中将我的 Service Worker 定义为持久的,因为我使用 webRequest API 来拦截在表单中为特定请求传递的一些数据,但我不知道如何做到这一点。我已经尝试了所有方法,但我的 Service Worker 一直在卸载。
如何保持加载并等待请求被拦截?
javascript google-chrome xmlhttprequest request google-chrome-extension