本文介绍了如何防止ServerXMLHTTP自动跟踪重定向(HTTP 303请参阅其他响应)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ServerXMLHTTP来执行HTTP POST。返回的响应是重定向(具体为303见其他)。 ServerXMLHTTP会自动跟随此重定向,但这会导致身份验证失败,因为它没有传播原始请求的Authorization标头。

I am using ServerXMLHTTP to perform an HTTP POST. The response returned is a redirect (specifically 303 See Other). ServerXMLHTTP is automatically following this redirect but this is causing an authentication failure as is not propagating the Authorization header of the original request.

有没有办法可以阻止自动重定向(或者确保重新发送Authorization标头)?

Is there a way I can prevent the automatic redirection (or alternatively ensure that the Authorization header is resent)?

推荐答案

ServerXMLHTTP不支持拦截重定向(请参阅)。但是,可以使用 WinHTTP 确实包含可配置的启用重定向选项。

ServerXMLHTTP does not support interception of redirects (see Microsoft Knowledge Base Article 308607). However WinHTTP can be used in its place and this does contain a configurable 'enable redirects' option.

如何在VBA中禁用WinHTTP重定向:

How to disable WinHTTP redirects in VBA:

webClient.Option(6) = False

在上下文中:

Set webClient = CreateObject("WinHttp.WinHttpRequest.5.1")
webClient.Option(6) = False
webClient.Open "POST", "http://example.com", False
webClient.send ("")

这篇关于如何防止ServerXMLHTTP自动跟踪重定向(HTTP 303请参阅其他响应)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 09:47