Libraries.Network.NetworkRequest Documentation

This class is used by the NetworkConnection class to create a request to be 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 key, text value)This method adds a header to a NetworkRequest object.
ApplyCharacterFormatting(text value)This method is used to format a text value in "url encode" format.
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.
FormEncodeData(Libraries.Data.Formats.JavaScriptObjectNotation data)This method is used to url encode a text value from a JavaScriptObjectNotation.
FormEncodeData(Libraries.Containers.HashTable<text:text> data)This method is used to url encode a text value from a HashTable.
GetBody()This method gets the body of the NetworkRequest object.
GetChunkLength()This method gets the size of the chunks if chunked length streaming mode is on in the NetworkRequest object.
GetConnectTimeout()This method gets the connection timeout value for the NetworkRequest object.
GetDoInput()This method returns a boolean value based on whether or not the NetworkRequest object will provide input to the server.
GetDoOutput()This method returns a boolean value based on whether or not the NetworkRequest object will get output from the server.
GetDownloadFile()Use this method to retrieve the file name from a NetworkRequest object for a file to be downloaded.
GetHashCode()This action gets the hash code for an object.
GetHeaders()This method gets a HashTable of the headers of a NetworkRequest object.
GetParameters()This method gets the parameters of the NetworkRequest object.
GetReadTimeout()This method returns the read timeout value of a NetworkRequest.
GetRequestType()This method gets the request type of a NetworkRequest object.
GetWebAddress()This method gets the web address for the NetworkRequest object.
IsChunkedStreamingMode()This method returns a boolean value to determine if chunked length streaming mode is on in the NetworkRequest object.
IsFixedLengthStreamingMode()This method returns a boolean value to determine if fixed length streaming mode is on in the NetworkRequest object.
SetBody(text data)This method sets the body of the NetworkRequest object.
SetBodyAsJavaScriptObjectNotation(Libraries.Containers.HashTable<text:text> data)This method sets the body of the NetworkRequest object as JavaScriptObjectNotation data from a JavaScriptObjectNotation object.
SetBodyAsJavaScriptObjectNotation(Libraries.Data.Formats.JavaScriptObjectNotation data)This method sets the body of the NetworkRequest object as JavaScriptObjectNotation data from a JavaScriptObjectNotation object.
SetChunkLength(integer chunkLength)This method sets the size of the chunks if chunked length streaming mode is on in the NetworkRequest object.
SetChunkedStreamingMode(boolean value)This method is sets the NetworkRequest to chunked streaming mode.
SetConnectTimeout(integer milliseconds)This method sets the connection timeout value for the NetworkRequest object.
SetDoInput(boolean value)This method sets NetworkRequest object to provide input to the server.
SetDoOutput(boolean value)This method sets NetworkRequest object to receive output from the server.
SetDownloadFile(Libraries.System.File downloadFile)Use this method to download a file from the internet.
SetDownloadFile(text downloadFile)Use this method to download a file from the internet.
SetFixedLengthStreamingMode(boolean value)This method is sets the NetworkRequest to fixed length streaming mode.
SetHeaders(Libraries.Containers.HashTable<text:text> headers)This method sets the headers of a NetworkRequest object from a HashTable.
SetParameters(Libraries.Data.Formats.JavaScriptObjectNotation data)This method sets the body of the NetworkRequest object as form encoded data from a JavaScriptObjectNotation object.
SetParameters(Libraries.Containers.HashTable<text:text> data)This method sets the parameters of the NetworkRequest object as form encoded data from a HashTable.
SetReadTimeout(integer milliseconds)This method sets the read timeout value of a NetworkRequest.
SetRequestType(Libraries.Network.NetworkRequestType type)This method is used to set the request type of a NetworkRequest
SetRequestTypeToDelete()This method is used to set the request type of a NetworkRequest to DELETE
SetRequestTypeToGet()This method is used to set the request type of a NetworkRequest to GET
SetRequestTypeToHead()This method is used to set the request type of a NetworkRequest to HEAD
SetRequestTypeToPatch()This method is used to set the request type of a NetworkRequest to PATCH
SetRequestTypeToPost()This method is used to set the request type of a NetworkRequest to POST
SetRequestTypeToPut()This method is used to set the request type of a NetworkRequest to PUT
SetWebAddress(text webAddress)This method sets the web address for the NetworkRequest object.

Actions Documentation

AddHeader(text key, text value)

This method adds a header to a NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:AddHeader("Accept-Encoding", "gzip, deflate")
        end
    end

Parameters

ApplyCharacterFormatting(text value)

This method is used to format a text value in "url encode" format.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation
    use Libraries.Containers.Iterator

    action FormEncodeData(JavaScriptObjectNotation data) returns text
        text result = ""
        Iterator<JavaScriptObjectNotation> it = data:GetIterator()
        repeat while it:HasNext()
            JavaScriptObjectNotation obj
            obj = it:Next()
            text key = obj:GetKey()
            result = result + key + "=" + obj:GetValue() + "&"
        end
        result = result:GetSubtext(0, result:GetSize() - 1)
        return ApplyCharacterFormatting(result)
    end

Parameters

Return

text: The formatted string.

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.

FormEncodeData(Libraries.Data.Formats.JavaScriptObjectNotation data)

This method is used to url encode a text value from a JavaScriptObjectNotation.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation
    use Libraries.Containers.Iterator

    action SetBodyAsFormEncodedData(JavaScriptObjectNotation data)
        text body = FormEncodeData(data)
    end

Parameters

Return

text: The formatted string.

FormEncodeData(Libraries.Containers.HashTable<text:text> data)

This method is used to url encode a text value from a HashTable.

Example Code

use Libraries.Containers.HashTable
    use Libraries.Containers.Iterator

    action SetBodyAsFormEncodedData(JavaScriptObjectNotation data)
        text body = FormEncodeData(data)
    end

Parameters

Return

text: The formatted string.

GetBody()

This method gets the body of the NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            text key = "name"
            text value = "John"
            NetworkRequest request
            request:SetBody(key + ":" + value)
            output request:GetBody()
        end
    end

Return

text: The body of the request object.

GetChunkLength()

This method gets the size of the chunks if chunked length streaming mode is on in the NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetChunkedStreamingMode(true)
            request:SetChunkLength(1000)
            output request:GetChunkLength()
        end
    end

Return

integer: The chunk size in bytes.

GetConnectTimeout()

This method gets the connection timeout value for the NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetConnectTimeout(1000)
            output request:GetConnectTimeout()
        end
    end

Return

integer: The timeeout value in milliseconds.

GetDoInput()

This method returns a boolean value based on whether or not the NetworkRequest object will provide input to the server.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetDoInput(true)
            output request:GetDoInput()
        end
    end

Return

boolean: A boolean value to indicate if the object will send input.

GetDoOutput()

This method returns a boolean value based on whether or not the NetworkRequest object will get output from the server.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetDoOutput(true)
            output request:GetDoOutput()
        end
    end

Return

boolean: A boolean value to indicate if the object will receive output.

GetDownloadFile()

Use this method to retrieve the file name from a NetworkRequest object for a file to be downloaded.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetDownloadFile("logo.png")
            output request:GetDownloadFile()
        end
    end

Return

text:

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.

GetHeaders()

This method gets a HashTable of the headers of a NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Containers.HashTable

    class Main
        action Main
            NetworkRequest request
            request:AddHeader("Accept-Encoding", "gzip, deflate")
            HashTable<text, text> headers = request:GetHeaders()
            output headers:GetValue("Accept-Encoding")
        end
    end

Return

Libraries.Containers.HashTable: A HashTable of headers.

GetParameters()

This method gets the parameters of the NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation data
            data:Add("first", "John")
            data:Add("last", "Doe")
            NetworkRequest request
            request:SetParameters(data)
            output request:GetParameters()
        end
    end

Return

text: The parameters of the request object.

GetReadTimeout()

This method returns the read timeout value of a NetworkRequest.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            output request:GetReadTimeout()
        end
    end

Return

integer: The read timeout value in milliseconds.

GetRequestType()

This method gets the request type of a NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetRequestTypeToPost()
            output request:GetRequestType()
        end
    end

Return

text: The type of request as text.

GetWebAddress()

This method gets the web address for the NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            output request:GetWebAddress()
        end
    end

Return

text: The web address of the object.

IsChunkedStreamingMode()

This method returns a boolean value to determine if chunked length streaming mode is on in the NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetChunkedStreamingMode(true)
            output request:IsChunkedStreamingMode()
        end
    end

Return

boolean: A boolean value indicating the setting of the mode.

IsFixedLengthStreamingMode()

This method returns a boolean value to determine if fixed length streaming mode is on in the NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetFixedLengthStreamingMode(false)
            output request:IsFixedLengthStreamingMode()
        end
    end

Return

boolean: A boolean value indicating the setting of the mode.

SetBody(text data)

This method sets the body of the NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            text key = "name"
            text value = "John"
            NetworkRequest request
            request:SetBody(key + ":" + value)
            output request:GetBody()
        end
    end

Parameters

SetBodyAsJavaScriptObjectNotation(Libraries.Containers.HashTable<text:text> data)

This method sets the body of the NetworkRequest object as JavaScriptObjectNotation data from a JavaScriptObjectNotation object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Containers.HashTable

    class Main
        action Main
            text key1 = "name"
            text value1 = "John"
            text key2 = "age"
            text value2 = "21"
            HashTable<text, text> data
            data:Add(key1, value1)
            data:Add(key2, value2)
            NetworkRequest request
            request:SetBodyAsJavaScriptObjectNotation(data)
            output request:GetBody()
        end
    end

Parameters

SetBodyAsJavaScriptObjectNotation(Libraries.Data.Formats.JavaScriptObjectNotation data)

This method sets the body of the NetworkRequest object as JavaScriptObjectNotation data from a JavaScriptObjectNotation object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            text key1 = "name"
            text value1 = "John"
            text key2 = "age"
            text value2 = "21"
            JavaScriptObjectNotation data
            data:Add(key1, value1)
            data:Add(key2, value2)
            NetworkRequest request
            request:SetBodyAsJavaScriptObjectNotation(data)
            output request:GetBody()
        end
    end

Parameters

SetChunkLength(integer chunkLength)

This method sets the size of the chunks if chunked length streaming mode is on in the NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetChunkedStreamingMode(true)
            request:SetChunkLength(1000)
            output request:GetChunkLength()
        end
    end

Parameters

SetChunkedStreamingMode(boolean value)

This method is sets the NetworkRequest to chunked streaming mode.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetChunkedStreamingMode(true)
            output request:IsChunkedStreamingMode()
        end
    end

Parameters

SetConnectTimeout(integer milliseconds)

This method sets the connection timeout value for the NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetConnectTimeout(1000)
            output request:GetConnectTimeout()
        end
    end

Parameters

SetDoInput(boolean value)

This method sets NetworkRequest object to provide input to the server.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetDoInput(false)
            output request:GetDoInput()
        end
    end

Parameters

SetDoOutput(boolean value)

This method sets NetworkRequest object to receive output from the server.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetDoOutput(false)
            output request:GetDoOutput()
        end
    end

Parameters

SetDownloadFile(Libraries.System.File downloadFile)

Use this method to download a file from the internet. Set the filename and path where you'd like the downloaded file to save on your local computer.

Example Code

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

    class Main is NetworkRequestListener

        action Main
            NetworkConnection conn
            conn:AddListener(me)
            File myFile
            myFile:SetPath("logo.png")
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/media/QuorumLogo.png")
            request:SetDownloadFile(myFile)

            conn:SendRequest(request)
        end

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

    end

Parameters

SetDownloadFile(text downloadFile)

Use this method to download a file from the internet. Set the filename and path where you'd like the downloaded file to save on your local computer.

Example Code

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

    class Main is NetworkRequestListener

        action Main
            NetworkConnection conn
            conn:AddListener(me)
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/media/QuorumLogo.png")
            request:SetDownloadFile("logo.png")
            conn:SendRequest(request)
        end

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

    end

Parameters

SetFixedLengthStreamingMode(boolean value)

This method is sets the NetworkRequest to fixed length streaming mode.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetFixedLengthStreamingMode(true)
            output request:IsFixedLengthStreamingMode()
        end
    end

Parameters

SetHeaders(Libraries.Containers.HashTable<text:text> headers)

This method sets the headers of a NetworkRequest object from a HashTable.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Containers.HashTable

    class Main
        action Main
            HashTable<text, text> headers
            headers:Add("Connection", "keep-alive")
            headers:Add("Accept-Encoding", "gzip, deflate")
            NetworkRequest request
            request:SetHeaders(headers)
            output headers:GetValue("Connection")
        end
    end

Parameters

SetParameters(Libraries.Data.Formats.JavaScriptObjectNotation data)

This method sets the body of the NetworkRequest object as form encoded data from a JavaScriptObjectNotation object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            text key1 = "name"
            text value1 = "John"
            text key2 = "age"
            text value2 = "21"
            JavaScriptObjectNotation data
            data:Add(key1, value1)
            data:Add(key2, value2)
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetParameters(data)
            output request:GetBody()
        end
    end

Parameters

SetParameters(Libraries.Containers.HashTable<text:text> data)

This method sets the parameters of the NetworkRequest object as form encoded data from a HashTable.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Containers.HashTable

    class Main
        action Main
            text key1 = "name"
            text value1 = "John"
            text key2 = "age"
            text value2 = "21"
            HashTable<text, text> data
            data:Add(key1, value1)
            data:Add(key2, value2)
            NetworkRequest request
            request:SetRequestTypeToPost()
            request:SetParameters(data)
            output request:GetParameters()
        end
    end

Parameters

SetReadTimeout(integer milliseconds)

This method sets the read timeout value of a NetworkRequest.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetReadTimeout(1000)
            output request:GetReadTimeout()
        end
    end

Parameters

SetRequestType(Libraries.Network.NetworkRequestType type)

This method is used to set the request type of a NetworkRequest

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkRequestType

    class Main
        action Main
            NetworkRequestType type
            type:SetToGet()
            NetworkRequest request
            request:SetRequestType(type)
        end
    end

Parameters

SetRequestTypeToDelete()

This method is used to set the request type of a NetworkRequest to DELETE

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetRequestTypeToDelete()
        end
    end

SetRequestTypeToGet()

This method is used to set the request type of a NetworkRequest to GET

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetRequestTypeToGet()
        end
    end

SetRequestTypeToHead()

This method is used to set the request type of a NetworkRequest to HEAD

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetRequestTypeToHead()
        end
    end

SetRequestTypeToPatch()

This method is used to set the request type of a NetworkRequest to PATCH

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetRequestTypeToPatch()
        end
    end

SetRequestTypeToPost()

This method is used to set the request type of a NetworkRequest to POST

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetRequestTypeToPost()
        end
    end

SetRequestTypeToPut()

This method is used to set the request type of a NetworkRequest to PUT

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetRequestTypeToPut()
        end
    end

SetWebAddress(text webAddress)

This method sets the web address for the NetworkRequest object.

Example Code

use Libraries.Network.NetworkRequest

    class Main
        action Main
            NetworkRequest request
            request:SetWebAddress("https://quorumlanguage.com/GETtest.php")
            output request:GetWebAddress()
        end
    end

Parameters