Example code for NotesHTTPRequest w/TLS 1.2.

Mindwatering Incorporated

Author: Tripp W Black

Created: 10/11/2018 at 11:23 PM

 

Category:
Notes Developer Tips
LotusScript

Example code for NotesHTTPRequest w/TLS 1.2 w/Domino 10.
(Adapted from code from Daniel Nashcom.)

The following code logs into a Domino 10 server.
It then displays the header contents for the current page (logged into).

Sub Initialize
Dim s As New NotesSession
Dim ret As String
Dim httpURL As String
Dim headers As Variant
Dim usernm As String
Dim userpwd As String
Dim webRequest As NotesHTTPRequest

' login to server
Set webRequest = s.CreateHttpRequest()
usernm = "testacct@mindwatering.net"
userpwd = "pwdfortestacct1"
webRequest.Maxredirects = 5
httpURL = "https://www.mindwatering.net?open&login"

Call webRequest.SetHeaderField("Authorization", "Basic " + EncodeBase64 (s, usernm + ":" + userpwd ))

' get returned response and loop through headers
ret = webRequest.Get(httpURL)
headers = webRequest.GetResponseHeaders()
ForAll header In headers
Print header
End ForAll

Print ret

End Sub
Function EncodeBase64 (s as NotesSession, inStr As String) As String
Dim stream As NotesStream
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim body As NotesMIMEEntity

' setup
Set db = s.CurrentDatabase
Set stream = s.CreateStream()
Call stream.WriteText (inStr)

' create temp doc to do base64 encoding
Set doc = db.CreateDocument
Set body = doc.CreateMIMEEntity

Call body.SetContentFromText (stream, "", ENC_NONE)
Call body.EncodeContent (ENC_BASE64)

EncodeBase64 = body.ContentAsText

Call stream.Close
Set doc = Nothing
End Function


previous page