Platforms to show: All Mac Windows Linux Cross-Platform
/MacCocoa/NSURLConnectionFilter test
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSURLConnectionFilter test
This example is the version from Wed, 17th Apr 2018.
Project "NSURLConnectionFilter test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class mainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open()
log CurrentMethodName
f = new MyNSURLConnectionFilterMBS
m = new MyHTTPSocket
m.send "GET", "http://www.monkeybreadsoftware.net"
End EventHandler
Property f As MyNSURLConnectionFilterMBS
Property m As MyHTTPSocket
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyHTTPSocket Inherits Xojo.Net.HTTPSocket
EventHandler Function AuthenticationRequired(Realm as Text, ByRef Name as Text, ByRef Password as Text) As Boolean
log CurrentMethodName
End EventHandler
EventHandler Sub Error(err as RuntimeException)
log CurrentMethodName
End EventHandler
EventHandler Sub FileReceived(URL as Text, HTTPStatus as Integer, File as xojo.IO.FolderItem)
log CurrentMethodName
End EventHandler
EventHandler Sub HeadersReceived(URL as Text, HTTPStatus as Integer)
log CurrentMethodName
End EventHandler
EventHandler Sub PageReceived(URL as Text, HTTPStatus as Integer, Content as xojo.Core.MemoryBlock)
log CurrentMethodName
log "HTTPStatus: "+str(HTTPStatus)
End EventHandler
EventHandler Sub ReceiveProgress(BytesReceived as Int64, TotalBytes as Int64, NewData as xojo.Core.MemoryBlock)
log CurrentMethodName+" "+str(BytesReceived)+"/"+str(TotalBytes)
End EventHandler
EventHandler Sub SendProgress(BytesSent as Int64, BytesLeft as Int64)
log CurrentMethodName+" "+str(BytesSent)+"/"+str(BytesSent + BytesLeft)
End EventHandler
End Class
Class MyNSURLConnectionFilterMBS Inherits NSURLConnectionFilterMBS
EventHandler Function FilterConnection(request as NSURLRequestMBS) As NSURLRequestMBS
log CurrentMethodName
log "URL: "+request.URL
dim newRequest as NSMutableURLRequestMBS = request.mutableCopy
// change to 10 minutes
newRequest.setTimeoutInterval 600
dim oldTimeout as Double = request.timeoutInterval
dim newTimeout as Double = newRequest.timeoutInterval
log "oldTimeout: "+str(oldTimeout)
log "newTimeout: "+str(newTimeout)
return newRequest
End EventHandler
End Class
Module UtilModule
Sub Log(s as string)
mainWindow.List.addrow s
End Sub
End Module
End Project
The items on this page are in the following plugins: MBS MacCocoa Plugin.