Libraries.Network.NetworkResponseEvent Documentation

This class is returned by the NetworkConnection class in response to a request made over the internet protocol. More information on the internet protocol, called Hyper Text Transfer Protocol (HTTP) can be found at: https://www.w3.org/Protocols/,

Example Code

use Libraries.Network.NetworkConnection
use Libraries.Network.NetworkRequest
use Libraries.Network.NetworkResponseEvent
use Libraries.Network.NetworkRequestListener

class Main is NetworkRequestListener
    action Main
        NetworkRequest request
        request:SetRequestTypeToGet()
        request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
        NetworkConnection http
        http:AddListener(me)
        http:SendRequest(request)
    end

    action ResponseReceived(NetworkResponseEvent response)
        output response:GetResponseText()
    end
end

Inherits from: Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
AddHeader(text name, text value)This method adds a header to the NetworkResponseEvent as a key value pair.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetContentLength()This method returns the value of the ContentLength field of the NetworkResponseEvent,
GetContentType()This method returns the value of the ContentType field of the NetworkResponseEvent,
GetEncoding()This method returns the value of the encoding field of the NetworkResponseEvent,
GetHashCode()This action gets the hash code for an object.
GetHeader(text key)This method returns the a specific header on the NetworkResponseEvent,
GetHeaders()This method returns a hash table with all the headers on the NetworkResponseEvent,
GetResponseText()This method returns the response text of the NetworkResponseEvent,
GetStatusCode()This method returns the status code of the NetworkResponseEvent,
GetStatusText()This method returns the status text of the NetworkResponseEvent,
GetWebAddress()This method returns the web address of the NetworkResponseEvent,
IsOk()This method checks if the status code of a NetworkResponseObject is a success value.
SetContentLength(integer length)This method sets the ContentLength of a NetworkResponseEvent.
SetContentType(text contentType)This method sets the ContentType of a NetworkResponseEvent.
SetEncoding(text encoding)This method sets the encoding of a NetworkResponseEvent.
SetResponseText(text responseText)This method sets the response text of a NetworkResponseEvent.
SetStatusCode(integer statusCode)This method sets the status text of a NetworkResponseEvent.
SetStatusText(text statusText)This method sets the status text of a NetworkResponseEvent.
SetWebAddress(text webAddress)This method sets the web address of a NetworkResponseEvent.

Actions Documentation

AddHeader(text name, text value)

This method adds a header to the NetworkResponseEvent as a key value pair. This method is primarily used by the library to populate the fields of the NetworkResponseEvent from the server.

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkResponseEvent

    action ReturnResponse(NetworkConnection http) returns NetworkResponseEvent
        NetworkResponseEvent response = http:GetResponseEvent()
        response:AddHeader("User-Agent", "Quorum Client")
        return response
    end

Parameters

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Example Code

Object o
        Object t
        integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Example Code

use Libraries.Language.Object
        use Libraries.Language.Types.Text
        Object o
        Text t
        boolean result = o:Equals(t)

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

GetContentLength()

This method returns the value of the ContentLength field of the NetworkResponseEvent,

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkRequestListener

    class Main is NetworkRequestListener
        action Main
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            NetworkConnection http
            http:AddListener(me)
            http:SendRequest(request)
        end

        action ResponseReceived(NetworkResponseEvent response)
            output response:GetContentLength()
        end
    end

Return

integer: The number of bytes of the ContentLength.

GetContentType()

This method returns the value of the ContentType field of the NetworkResponseEvent,

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkRequestListener

    class Main is NetworkRequestListener
        action Main
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            NetworkConnection http
            http:AddListener(me)
            http:SendRequest(request)
        end

        action ResponseReceived(NetworkResponseEvent response)
            output response:GetContentType()
        end
    end

Return

text: The type of the content of the NetworkResponseEvent.

GetEncoding()

This method returns the value of the encoding field of the NetworkResponseEvent,

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkRequestListener

    class Main is NetworkRequestListener
        action Main
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            NetworkConnection http
            http:AddListener(me)
            http:SendRequest(request)
        end

        action ResponseReceived(NetworkResponseEvent response)
            output response:GetEncoding()
        end
    end

Return

text: The type of encoding of the NetworkResponseEvent.

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetHeader(text key)

This method returns the a specific header on the NetworkResponseEvent,

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkRequestListener

    class Main is NetworkRequestListener
        action Main
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            NetworkConnection http
            http:AddListener(me)
            http:SendRequest(request)
        end

        action ResponseReceived(NetworkResponseEvent response)
            output response:GetHeader("User-Agent")
        end
    end

Parameters

Return

text: The header for a given key.

GetHeaders()

This method returns a hash table with all the headers on the NetworkResponseEvent,

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkRequestListener

    class Main is NetworkRequestListener
        action Main
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            NetworkConnection http
            http:AddListener(me)
            http:SendRequest(request)
        end

        action ResponseReceived(NetworkResponseEvent response)
            HashTable<text, text> headers = response:GetHeaders()
        end
    end

Return

Libraries.Containers.HashTable: A hash table list of the headers.

GetResponseText()

This method returns the response text of the NetworkResponseEvent,

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkRequestListener

    class Main is NetworkRequestListener
        action Main
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            NetworkConnection http
            http:AddListener(me)
            http:SendRequest(request)
        end

        action ResponseReceived(NetworkResponseEvent response)
            output response:GetResponseText()
        end
    end

Return

text: The response text.

GetStatusCode()

This method returns the status code of the NetworkResponseEvent,

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkRequestListener

    class Main is NetworkRequestListener
        action Main
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            NetworkConnection http
            http:AddListener(me)
            http:SendRequest(request)
        end

        action ResponseReceived(NetworkResponseEvent response)
            output response:GetStatusCode()
        end
    end

Return

integer: The status text.

GetStatusText()

This method returns the status text of the NetworkResponseEvent,

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkRequestListener

    class Main is NetworkRequestListener
        action Main
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            NetworkConnection http
            http:AddListener(me)
            http:SendRequest(request)
        end

        action ResponseReceived(NetworkResponseEvent response)
            output response:GetStatusText()
        end
    end

Return

text: The status text.

GetWebAddress()

This method returns the web address of the NetworkResponseEvent,

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkRequestListener

    class Main is NetworkRequestListener
        action Main
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            NetworkConnection http
            http:AddListener(me)
            http:SendRequest(request)
        end

        action ResponseReceived(NetworkResponseEvent response)
            output response:GetWebAddress()
        end
    end

Return

text: The web address.

IsOk()

This method checks if the status code of a NetworkResponseObject is a success value.

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkRequestListener

    class Main is NetworkRequestListener
        action Main
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            NetworkConnection http
            http:AddListener(me)
            http:SendRequest(request)
        end

        action ResponseReceived(NetworkResponseEvent response)
            output response:IsOk()
        end
    end

Return

boolean: A boolean value indicating if the status code is a success value.

SetContentLength(integer length)

This method sets the ContentLength of a NetworkResponseEvent. This method is primarily used by the library to populate the fields of the NetworkResponseEvent from the server.

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkResponseEvent

    action ReturnResponse(NetworkConnection http) returns NetworkResponseEvent
        NetworkResponseEvent response = http:GetResponseEvent()
        response:SetContentLength(120)
        return response
    end

Parameters

SetContentType(text contentType)

This method sets the ContentType of a NetworkResponseEvent. This method is primarily used by the library to populate the fields of the NetworkResponseEvent from the server.

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkResponseEvent

    action ReturnResponse(NetworkConnection http) returns NetworkResponseEvent
        NetworkResponseEvent response = http:GetResponseEvent()
        response:SetContentType("text/html; charset=utf-8")
        return response
    end

Parameters

SetEncoding(text encoding)

This method sets the encoding of a NetworkResponseEvent. This method is primarily used by the library to populate the fields of the NetworkResponseEvent from the server.

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkResponseEvent

    action ReturnResponse(NetworkConnection http) returns NetworkResponseEvent
        NetworkResponseEvent response = http:GetResponseEvent()
        response:SetEncoding("gzip")
        return response
    end

Parameters

SetResponseText(text responseText)

This method sets the response text of a NetworkResponseEvent. This method is primarily used by the library to populate the fields of the NetworkResponseEvent from the server.

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkResponseEvent

    action ReturnResponse(NetworkConnection http) returns NetworkResponseEvent
        NetworkResponseEvent response = http:GetResponseEvent()
        response:SetResponseText("Hello World!")
        return response
    end

Parameters

SetStatusCode(integer statusCode)

This method sets the status text of a NetworkResponseEvent. This method is primarily used by the library to populate the fields of the NetworkResponseEvent from the server.

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkResponseEvent

    action ReturnResponse(NetworkConnection http) returns NetworkResponseEvent
        NetworkResponseEvent response = http:GetResponseEvent()
        response:SetStatusCode(200)
        return response
    end

Parameters

SetStatusText(text statusText)

This method sets the status text of a NetworkResponseEvent. This method is primarily used by the library to populate the fields of the NetworkResponseEvent from the server.

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkResponseEvent

    action ReturnResponse(NetworkConnection http) returns NetworkResponseEvent
        NetworkResponseEvent response = http:GetResponseEvent()
        response:SetStatusText("OK")
        return response
    end

Parameters

SetWebAddress(text webAddress)

This method sets the web address of a NetworkResponseEvent. This method is primarily used by the library to populate the fields of the NetworkResponseEvent from the server.

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkResponseEvent

    action ReturnResponse(NetworkConnection http) returns NetworkResponseEvent
        NetworkResponseEvent response = http:GetResponseEvent()
        response:SetWebAddress("quorumlanguage.com)
        return response
    end

Parameters