我正在尝试将一些旧式的Groovy HttpBuilder代码转换为HttpBuilder-NG。我必须做的一件事就是添加请求拦截器以处理基本授权。这就是我在旧的HttpBuilder
中做到的def http = new RESTClient(url)
http.client.addRequestInterceptor(new HttpRequestInterceptor() {
void process(HttpRequest httpRequest, HttpContext httpContext) {
log.debug("Request intercepted, adding authorization")
httpRequest.addHeader('Authorization','Basic ' + "${username}:${password}".bytes.encodeBase64().toString())
}
})
return http
如何在HttpBuilder-NG中完成? (是的,我一直在阅读用户指南)。
2017年5月16日更新
我问,因为使用ApacheHttpBuilder,它会在日志中得到它。
DEBUG - Authentication required
DEBUG - gpdevjira.broadinstitute.org:8443 requested authentication
DEBUG - Authentication schemes in the order of preference: [Negotiate, Kerberos, NTLM, Digest, Basic]
DEBUG - Challenge for Negotiate authentication scheme not available
DEBUG - Challenge for Kerberos authentication scheme not available
DEBUG - Challenge for NTLM authentication scheme not available
DEBUG - Challenge for Digest authentication scheme not available
DEBUG - Challenge for Basic authentication scheme not available
我能够使用旧的HttpBuilder和请求拦截器来处理基本身份验证。
答案 0 :(得分:0)
如果你因为JIRA在这里是错误的行为。文档中声明的内容不起作用 - 不是由于客户端库问题,而是JIRA有一些特殊行为。
以下代码正常工作
Sub Main()
Dim x As Integer = Console.ReadLine
Dim isn As Decimal = Console.ReadLine
Dim fsn As Decimal = Console.ReadLine
Dim inc As Decimal = Console.ReadLine
For m = isn To fsn Step inc
Dim r As Double = x * m
Dim r_string As String = r.ToString
If r_string.Contains(".") Then
Else
Console.WriteLine(r)
End If
Next
Console.ReadLine()
End Sub