Class Request


  • public class Request
    extends java.lang.Object
    Describes an HTTP request.

    A Request object is created by calling WebBrowser.createRequest(HttpMethod, Url). The request can then be sent to the web server using the send() or sendTopLevel() methods.

    e.g.

     
     Request request1 = getWebBrowser().createRequest(HttpMethod.GET, new Url("http://www.testplant.com/"), 1); 
     Response response1 = request1.send(); 
     
    See Also:
    Response
    • Constructor Summary

      Constructors 
      Constructor Description
      Request​(long cPtr, boolean cMemoryOwn)
      For internal use only.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addKeepSubRequestContentType​(java.lang.String typeFragment)
      Adds a Content-Type fragment, so the content of sub-request responses that match the specified Content-Type fragment will be kept.
      void addKeepSubRequestContentUrl​(java.lang.String urlFragment)
      Adds a URL, so the content of sub-request responses that match the specified URL fragment will be kept.
      void addSubRequest​(Protocol protocol, IpEndPoint ipEndPoint, java.lang.String path)
      Adds a URL to the list of sub-requests that will be fetched from the web server by this request.
      void addSubRequest​(Url url)
      Adds a Url to the list of sub-requests that will be fetched from the web server by this request.
      void addSubRequest​(java.lang.String resource)
      Adds a URL to the list of sub-requests that will be fetched from the web server by this request.
      void clearHeaders()
      Clears the list of HTTP headers for this Request.
      boolean containsHeader​(java.lang.String header)
      Returns true if this Request contains a particular HTTP header.
      void delete()  
      void end()
      Ends this request - this method should be called when either sendTopLevel() or sendSubRequests(Response) has been called.
      java.lang.String getCharactersAllowedInPostedForm()
      Gets the characters that will NOT be percent-encoded when a Form is sent to the web server using a POST request.
      int getChunkSize()
      Gets the size in bytes of the chunk size to use when sending data using Transfer-Encoding: chunked
      java.lang.String getContentType()
      Gets the value of the "Content-Type" HTTP header.
      java.util.List<java.lang.String> getContentTypeFragments()
      Gets a list of all the Content-Type fragments for which the content of sub-request responses will be kept.
      java.util.List<java.lang.String> getContentUrlFragments()
      Gets a list of all the URL fragments for which the content of sub-request responses will be kept.
      static long getCPtr​(Request obj)
      For internal use only.
      boolean getFollowRedirects()
      Returns true if redirects will automatically be followed for this Request.
      java.util.List<java.lang.String> getHeaderKeys()
      Gets a list of names of all the HTTP request headers set in this Request.
      java.lang.String getHeaderValue​(java.lang.String header)
      Gets the value of the specified HTTP request header.
      HttpStatusCategory getHttpStatusCategory​(HttpStatus status)
      Returns the registered status category for the given HTTP status.
      int getID()
      Gets the unique ID that has been assigned to this Request.
      java.util.List<Url> getIgnoredSubRequests()
      Gets the list of sub-requests that will be ignored when fetching sub-requests from the web server.
      boolean getIncludeQueryDataInLabels()
      Returns true if URLs with different query data should be considered different from each other for analysis purposes.
      boolean getKeepAllSubRequestContent()
      Returns true if the content of responses to sub-requests will be kept.
      boolean getKeepContent()
      Returns true if the content of responses will be kept.
      java.lang.String getMessageBody()
      Gets the body of the HTTP request that will be sent to the server.
      HttpMethod getMethod()
      Gets the HTTP method that this Request uses (e.g. HttpMethod.GET or HttpMethod.POST).
      int getReference()
      Gets the reference id that was passed to the WebBrowser.createRequest(HttpMethod, Url, int) method when this Request object was created.
      java.lang.String getReferer()
      Gets the value of the "Referer" HTTP header.
      boolean getRetrieveSubRequests()
      Returns true if sub-requests will be retrieved for this Request.
      java.util.List<Url> getSubRequests()
      Gets the list of sub-requests that will be fetched from the web server by this request.
      int getSubRequestThreadCount()
      Gets the number of threads that will be used to fetch sub-requests from the web server.
      boolean getTimeEveryHttpRequest()
      Returns true if sub-requests will be timed as well as top-level HTTP requests.
      Url getUrl()
      Gets the Url that this Request is targeting.
      java.lang.String getUserAgent()
      Gets the value of the "User-Agent" HTTP header.
      java.lang.String getVersion()
      Gets the HTTP version as a String.
      boolean hasReferer()
      Returns true if the "Referer" HTTP header has been set for this Request.
      void ignoreSubRequest​(Protocol protocol, IpEndPoint ipEndPoint, java.lang.String path)
      Specifies a URL that will be ignored when fetching sub-requests from the web server.
      void ignoreSubRequest​(Url url)
      Specifies a Url that will be ignored when fetching sub-requests from the web server.
      void ignoreSubRequest​(java.lang.String resource)
      Specifies a URL that will be ignored when fetching sub-requests from the web server.
      boolean isDynatraceIntegrationEnabled()
      Returns true if dynaTrace integration is enabled.
      void removeHeader​(java.lang.String header)
      Removes an HTTP header from this Request.
      void removeKeepSubRequestContentType​(java.lang.String typeFragment)
      Removes a Content-Type fragment, so the content of sub-request responses that match the specified Content-Type fragment will no longer be kept.
      void removeKeepSubRequestContentUrl​(java.lang.String urlFragment)
      Removes a URL, so the content of sub-request responses that match the specified URL fragment will no longer be kept.
      Response send()
      Sends this request and any sub-requests to the web server, and waits for all the responses to be served.
      void sendSubRequests​(Response response)
      Sends the sub-requests for this request to the web server, and waits for the responses.
      Response sendTopLevel()
      Sends this request to the web server, and waits for the response to be served, but doesn't send any sub-requests.
      void setCharactersAllowedInPostedForm​(java.lang.String charactersAllowedInPostedForm)
      Sets the characters that will NOT be percent-encoded when a Form is sent to the web server using a POST request.
      void setChunkSize​(int chunkSize)
      Sets the size in bytes of the chunk size to use when sending data using Transfer-Encoding: chunked
      void setContentType​(java.lang.String contentType)
      Sets the value of the "Content-Type" HTTP header.
      void setDynatraceIntegrationEnabled​(boolean value)
      Sets whether or not dynaTrace integration is enabled.
      void setFollowRedirects()
      Sets the behaviour of this Request so redirects will automatically be followed.
      void setFollowRedirects​(boolean followRedirects)
      Sets whether redirects will automatically be followed for this Request.
      void setHeader​(java.lang.String header)
      Sets an HTTP header for this Request.
      void setHeader​(java.lang.String header, java.lang.String value)
      Sets an HTTP header for this Request.
      void setHttpStatusCategory​(HttpStatusRange statusRange, HttpStatusCategory category)
      Registers the provided HTTP status code range against the predefined category.
      void setHttpStatusCategory​(HttpStatus status, HttpStatusCategory category)
      Registers the provided HTTP status code range against the predefined category.
      void setIgnoredSubRequests​(java.util.List<Url> ignoreList)
      Sets the list of sub-requests that will be ignored when fetching sub-requests from the web server.
      void setIncludeQueryDataInLabels​(boolean includeQueryDataInLabels)
      Sets whether URLs with different query data should be considered different from each other for analysis purposes.
      void setKeepAlive​(boolean f)
      Sets the value of the "Connection" request header.
      void setKeepAllSubRequestContent​(boolean keep)
      Sets whether the content of responses to sub-requests should be kept.
      void setKeepContent​(boolean keep)
      Sets whether to keep the content of responses.
      void setMessageBody​(byte[] messageBody)
      Sets the body of the HTTP request that will be sent to the server.
      void setMessageBody​(Form form)
      Sets the body of the HTTP request that will be sent to the server, as name/value pairs extracted from the specified Form object.
      void setMessageBody​(java.lang.String messageBody)
      Sets the body of the HTTP request that will be sent to the server.
      void setMessageBody​(java.lang.String messageBody, java.lang.String encoding)
      Sets the body of the HTTP request that will be sent to the server, specifying the character encoding to use to encode the post data.
      void setMessageBodyFromFile​(java.lang.String fileName)
      Sets the body of the HTTP request that will be sent to the server, by loading data from a data file.
      void setOffsetEdit​(OffsetEditSequence edits)
      Sets an OffsetEditSequence object to be applied to the message body of this Request object, immediately before the request is sent to the web server.
      void setReferer​(Url url)
      Sets the value of the "Referer" HTTP header.
      void setReferer​(java.lang.String referer)
      Sets the value of the "Referer" HTTP header.
      void setRetrieveSubRequests​(boolean getEmbeddedUrls)
      Sets whether sub-requests will be retrieved for this Request.
      void setSubRequests​(java.util.List<Url> resourceList)
      Sets the list of sub-requests that will be fetched from the web server by this request.
      void setSubRequestThreadCount​(int subRequestThreadCount)
      Sets the number of threads that will be used to fetch sub-requests from the web server.
      void setTimeEveryHttpRequest​(boolean timings)
      Sets whether sub-requests should be timed as well as top-level HTTP requests.
      void setUrl​(Url url)
      Sets the Url that this Request is targeting.
      void setUserAgent​(java.lang.String userAgent)
      Sets the value of the "User-Agent" HTTP header.
      void setVersion​(java.lang.String version)
      Sets the HTTP version.
      void unsetReferer()
      Removes the "Referer" HTTP header.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Request

        public Request​(long cPtr,
                       boolean cMemoryOwn)
        For internal use only. Of no interest to the user.
        Parameters:
        cPtr - pointer to the CPP wrapped object
        cMemoryOwn - indicates if this object is responsible for memory management of the CPP object
    • Method Detail

      • getCPtr

        public static long getCPtr​(Request obj)
        For internal use only. Of no interest to the user.
        Parameters:
        obj - a reference to an object of this class
        Returns:
        a long containing the address of the CPP wrapped object
      • delete

        public void delete()
      • setUrl

        public void setUrl​(Url url)
        Sets the Url that this Request is targeting.
        Parameters:
        url - the target Url
        See Also:
        getUrl()
      • send

        public Response send()
                      throws java.lang.Exception
        Sends this request and any sub-requests to the web server, and waits for all the responses to be served. The top-level request is sent first. Once the server has responded, a list of sub-requests is compiled. This list is made up of:

        For example:

        
         Url url1 = new Url(protocol1, localhost, "/");
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         request1.addSubRequest(protocol1, localhost, "/Themes/TestPlant/Content/images/orange_button_bg.gif");
         Response response1 = request1.send();
         
        In this example, eggPlant Performance will first make an HTTP GET request to the url specified by url1 (http://localhost/). Once the server responds, eggPlant Performance will parse the HTML in the response, looking for additional resources that need to be downloaded (such as images, stylesheets or javascript files). These resources will be requested from the server. In addition, the sub-request that has been explicitly added using addSubRequest(Url) (http://localhost/Themes/TestPlant/Content/images/orange_button_bg.gif) will also be requested from the server.
        Returns:
        a Response object that describes the HTTP response from the server, including any sub-responses
        Throws:
        java.lang.Exception - There was an error when sending the request
        See Also:
        addSubRequest(String), ignoreSubRequest(String), setSubRequests(List), setIgnoredSubRequests(List), sendTopLevel(), sendSubRequests(Response), setSubRequestThreadCount(int)
      • sendTopLevel

        public Response sendTopLevel()
                              throws java.lang.Exception
        Sends this request to the web server, and waits for the response to be served, but doesn't send any sub-requests. This is unlike send() which also sends sub-requests. You can send the sub-requests later by calling sendSubRequests(Response).

        e.g.

        
         Url url1 = new Url(protocol1, localhost, "/");
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         // Send the top-level request only 
         Response response1 = request1.sendTopLevel();
         // Now send the sub-requests 
         request1.sendSubRequests(response1);
         // We must call end() when we have finished with this request
         request1.end();
         
        Returns:
        the Response to the top-level request. Note that this will not contain any sub-responses
        Throws:
        java.lang.Exception - There was an error when sending the request
        See Also:
        send(), sendSubRequests(Response), end()
      • setMessageBody

        public void setMessageBody​(java.lang.String messageBody)
        Sets the body of the HTTP request that will be sent to the server. This method is normally used with a POST or PUT request.

        e.g.

        
         Url url32 = new Url(protocol1, localhost, "/login");
         Request request32 = getWebBrowser().createRequest(HttpMethod.POST, url32, 32);
         request32.setMessageBody("Email=user@facilita.com&Password=password&RememberMe=false");
         Response response32 = request32.send();
         
        Parameters:
        messageBody - the body of the message (e.g. the POST data)
        See Also:
        setMessageBody(Form), setMessageBody(byte[]), setMessageBodyFromFile(String)
      • setMessageBody

        public void setMessageBody​(java.lang.String messageBody,
                                   java.lang.String encoding)
                            throws java.io.UnsupportedEncodingException
        Sets the body of the HTTP request that will be sent to the server, specifying the character encoding to use to encode the post data. This method is normally used with a POST or PUT request.

        e.g.

        
         Url url32 = new Url(protocol1, localhost, "/login");
         Request request32 = getWebBrowser().createRequest(HttpMethod.POST, url32, 32);
         request32.setMessageBody("Email=user@facilita.com&Password=password&RememberMe=false", "UTF-8");
         Response response32 = request32.send();
         
        Parameters:
        messageBody - the body of the message (e.g. the POST data)
        encoding - the character encoding to use when encoding the message body
        Throws:
        java.io.UnsupportedEncodingException - The specified encoding is not supported.
        See Also:
        setMessageBody(String), setMessageBody(byte[]), setMessageBodyFromFile(String)
      • sendSubRequests

        public void sendSubRequests​(Response response)
                             throws java.lang.Exception
        Sends the sub-requests for this request to the web server, and waits for the responses. The response parameter should be the Response object that was returned by a call to sendTopLevel().

        This method will compile a list of sub-requests to send to the web server. This list is made up of:

        The sub-responses will be attached to the Response object that is passed in, and can be accessed by calling the Response.getSubResponses() method.

        e.g.

        
         Url url1 = new Url(protocol1, localhost, "/");
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         // Send the top-level request only 
         Response response1 = request1.sendTopLevel();
         // Now send the sub-requests 
         request1.sendSubRequests(response1);
         // We must call end() when we have finished with this request
         request1.end();
         
        Parameters:
        response - the Response object returned by a call to sendTopLevel()
        Throws:
        java.lang.Exception - An error occurred when sending the sub-requests
        See Also:
        send(), sendTopLevel(), end(), setSubRequestThreadCount(int)
      • end

        public void end()
        Ends this request - this method should be called when either sendTopLevel() or sendSubRequests(Response) has been called. It tells eggPlant Performance that no more HTTP requests will be made as part of this Request object.

        Note that it is not necessary to call this method if you have called send() rather than sendTopLevel() or sendSubRequests(Response).

        e.g.

        
         Url url1 = new Url(protocol1, localhost, "/");
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         // Send the top-level request only 
         Response response1 = request1.sendTopLevel();
         // Now send the sub-requests 
         request1.sendSubRequests(response1);
         // We must call end() when we have finished with this request
         request1.end();
         
        See Also:
        sendTopLevel(), sendSubRequests(Response)
      • getSubRequests

        public java.util.List<Url> getSubRequests()
                                           throws com.facilita.exception.InternalError
        Gets the list of sub-requests that will be fetched from the web server by this request. The sub-requests will be fetched when send() or sendSubRequests(Response) are called.
        Returns:
        the list of sub-requests that will be fetched from the web server by this request
        Throws:
        com.facilita.exception.InternalError - An internal error occurred
      • setSubRequests

        public void setSubRequests​(java.util.List<Url> resourceList)
        Sets the list of sub-requests that will be fetched from the web server by this request. The sub-requests will be fetched when send() or sendSubRequests(Response) are called.

        e.g.

        
         Url url1 = new Url(protocol1, localhost, "/");
         // Create a GET request
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         
         // Create a list of sub-requests
         List%lt;Url> subRequests = new ArrayList<Url>();
         subRequests.add(new Url(protocol1, localhost, "/Themes/TestPlant/Content/images/orange_button_bg.gif"));
         subRequests.add(new Url(protocol1, localhost, "/Themes/TestPlant/Content/images/bg_maincolumn_3.gif"));
         subRequests.add(new Url(protocol1, localhost, "/Themes/TestPlant/Content/images/logo-reflection.gif"));
         // Attach the list of sub-requests to the top-level request
         request1.setSubRequests(subRequests);
         // Send the top-level request to the server, followed by all of the sub-requests 
         Response response1 = request1.send();
         
        Parameters:
        resourceList - the list of sub-requests that should be fetched
        See Also:
        send(), sendSubRequests(Response), addSubRequest(String), ignoreSubRequest(String)
      • getIgnoredSubRequests

        public java.util.List<Url> getIgnoredSubRequests()
                                                  throws com.facilita.exception.InternalError
        Gets the list of sub-requests that will be ignored when fetching sub-requests from the web server. Any requests included in this list will not be downloaded, even if references to them are found in the HTML of the top-level request.
        Returns:
        the list of sub-requests that will be ignored when fetching sub-requests from the web server.
        Throws:
        com.facilita.exception.InternalError - an internal error occurred
      • setIgnoredSubRequests

        public void setIgnoredSubRequests​(java.util.List<Url> ignoreList)
        Sets the list of sub-requests that will be ignored when fetching sub-requests from the web server. Any requests included in this list will not be downloaded, even if references to them are found in the HTML of the top-level request.

        e.g.

        
         Url url1 = new Url(protocol1, localhost, "/");
         // Create a GET request
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         
         // Create a list of sub-requests
         List<Url> subRequests = new ArrayList<Url>();
         subRequests.add(new Url(protocol1, localhost, "/Themes/TestPlant/Content/images/orange_button_bg.gif"));
         subRequests.add(new Url(protocol1, localhost, "/Themes/TestPlant/Content/images/bg_maincolumn_3.gif"));
         subRequests.add(new Url(protocol1, localhost, "/Themes/TestPlant/Content/images/logo-reflection.gif"));
         // Specify that all requests on this list should be ignored when fetching sub-requests
         request1.setIgnoredSubRequests(subRequests);
         Response response1 = request1.send();
         
        Parameters:
        ignoreList - the list of sub-requests to ignore
        See Also:
        send(), sendSubRequests(Response), ignoreSubRequest(String), addSubRequest(String)
      • ignoreSubRequest

        public void ignoreSubRequest​(Url url)
        Specifies a Url that will be ignored when fetching sub-requests from the web server. This URL will not be downloaded, even if a reference to it is found in the HTML of the top-level request.

        e.g.

        
         Url url1 = new Url(protocol1, localhost, "/");
         // Create a GET request
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         
         // Specify the sub-requests to ignore
         request1.ignoreSubRequest(new Url(protocol1, localhost, "/Themes/TestPlant/Content/images/orange_button_bg.gif"));
         request1.ignoreSubRequest(new Url(protocol1, localhost, "/Themes/TestPlant/Content/images/bg_maincolumn_3.gif"));
         request1.ignoreSubRequest(new Url(protocol1, localhost, "/Themes/TestPlant/Content/images/logo-reflection.gif"));
         Response response1 = request1.send();
         
        Parameters:
        url - the sub-request to ignore
        See Also:
        send(), sendSubRequests(Response), ignoreSubRequest(String), setIgnoredSubRequests(List), addSubRequest(String)
      • ignoreSubRequest

        public void ignoreSubRequest​(java.lang.String resource)
        Specifies a URL that will be ignored when fetching sub-requests from the web server. This URL will not be downloaded, even if a reference to it is found in the HTML of the top-level request.

        e.g.

        
         Url url1 = new Url(protocol1, localhost, "/");
         // Create a GET request
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         
         // Specify the sub-request to ignore
         request1.ignoreSubRequest("http://localhost/Themes/TestPlant/Content/images/orange_button_bg.gif");
         Response response1 = request1.send();
         
        Parameters:
        resource - the sub-request to ignore
        See Also:
        send(), sendSubRequests(Response), ignoreSubRequest(Url), setIgnoredSubRequests(List), addSubRequest(String)
      • ignoreSubRequest

        public void ignoreSubRequest​(Protocol protocol,
                                     IpEndPoint ipEndPoint,
                                     java.lang.String path)
                              throws NoSuchValueException
        Specifies a URL that will be ignored when fetching sub-requests from the web server. This URL will not be downloaded, even if a reference to it is found in the HTML of the top-level request.

        e.g.

        
         Url url1 = new Url(protocol1, localhost, "/");
         // Create a GET request
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         
         // Specify the sub-requests to ignore
         request1.ignoreSubRequest(protocol1, localhost, "/Themes/TestPlant/Content/images/orange_button_bg.gif");
         request1.ignoreSubRequest(protocol1, localhost, "/Themes/TestPlant/Content/images/bg_maincolumn_3.gif");
         request1.ignoreSubRequest(protocol1, localhost, "/Themes/TestPlant/Content/images/logo-reflection.gif");
         Response response1 = request1.send();
         
        Parameters:
        protocol - the protocol of the sub-request to ignore
        ipEndPoint - the IpEndPoint of the sub-request to ignore
        path - the path of the sub-request to ignore
        Throws:
        NoSuchValueException - the Protocol is not valid
        See Also:
        send(), sendSubRequests(Response), ignoreSubRequest(Url), setIgnoredSubRequests(List), addSubRequest(String)
      • addSubRequest

        public void addSubRequest​(Url url)
        Adds a Url to the list of sub-requests that will be fetched from the web server by this request. The sub-requests will be fetched when send() or sendSubRequests(Response) are called.

        e.g.

        
         Url url1 = new Url(protocol1, localhost, "/");
         // Create a GET request
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         
         // Add a sub-request
         request1.addSubRequest(new Url(protocol1, localhost, "/Themes/TestPlant/Content/images/orange_button_bg.gif"));
         // Send the top-level request to the server, followed by all of the sub-requests 
         Response response1 = request1.send();
         
        Parameters:
        url - the url that should be fetched
        See Also:
        send(), sendSubRequests(Response), addSubRequest(String), ignoreSubRequest(String)
      • addSubRequest

        public void addSubRequest​(java.lang.String resource)
        Adds a URL to the list of sub-requests that will be fetched from the web server by this request. The sub-requests will be fetched when send() or sendSubRequests(Response) are called.

        e.g.

        
         Url url1 = new Url(protocol1, localhost, "/");
         // Create a GET request
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         
         // Add a sub-request
         request1.addSubRequest("http://localhost/Themes/TestPlant/Content/images/orange_button_bg.gif");
         // Send the top-level request to the server, followed by all of the sub-requests 
         Response response1 = request1.send();
         
        Parameters:
        resource - the url that should be fetched
        See Also:
        send(), sendSubRequests(Response), addSubRequest(Url), ignoreSubRequest(String)
      • addSubRequest

        public void addSubRequest​(Protocol protocol,
                                  IpEndPoint ipEndPoint,
                                  java.lang.String path)
                           throws NoSuchValueException
        Adds a URL to the list of sub-requests that will be fetched from the web server by this request. The sub-requests will be fetched when send() or sendSubRequests(Response) are called.

        e.g.

        
         Url url1 = new Url(protocol1, localhost, "/");
         // Create a GET request
         Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1);
         
         // Add a sub-request
         request1.addSubRequest(protocol1, localhost, "/Themes/TestPlant/Content/images/orange_button_bg.gif");
         // Send the top-level request to the server, followed by all of the sub-requests 
         Response response1 = request1.send();
         
        Parameters:
        protocol - the Protocol of the url
        ipEndPoint - the IpEndPoint of the url
        path - the path of the url
        Throws:
        NoSuchValueException - the Protocol is not valid
        See Also:
        send(), sendSubRequests(Response), addSubRequest(Url), ignoreSubRequest(String)
      • setKeepAlive

        public void setKeepAlive​(boolean f)
        Sets the value of the "Connection" request header.
        • If the parameter is set to true, then the "Connection" header will be assigned the value "Keep-Alive".
        • If the parameter is set to false, then the "Connection" header will be removed.
        Parameters:
        f - true if the "Connection: Keep-Alive" request header should be set
      • setOffsetEdit

        public void setOffsetEdit​(OffsetEditSequence edits)
        Sets an OffsetEditSequence object to be applied to the message body of this Request object, immediately before the request is sent to the web server.
        Parameters:
        edits - an OffsetEditSequence object, which can contain multiple edits
      • setMessageBody

        public void setMessageBody​(byte[] messageBody)
        Sets the body of the HTTP request that will be sent to the server. This method is normally used with a POST or PUT request.

        e.g.

        
         Url url32 = new Url(protocol1, localhost, "/login");
         Request request32 = getWebBrowser().createRequest(HttpMethod.POST, url32, 32);
         request32.setMessageBody(new byte[] { 0x01, 0x02, 0x03});
         Response response32 = request32.send();
         
        Parameters:
        messageBody - the body of the message (e.g. the POST data)
        See Also:
        setMessageBody(String), setMessageBody(Form), setMessageBodyFromFile(String)
      • setMessageBodyFromFile

        public void setMessageBodyFromFile​(java.lang.String fileName)
        Sets the body of the HTTP request that will be sent to the server, by loading data from a data file. This method is normally used with a POST or PUT request.

        If you are using this method in your script, make sure that the file containing the data is in the Data/Files directory within your project.

        e.g.

        
         Url url32 = new Url(protocol1, localhost, "/uploadFile");
         Request request32 = getWebBrowser().createRequest(HttpMethod.POST, url32, 32);
         request32.setMessageBodyFromFile("myDoc.doc");
         Response response32 = request32.send();
         
        Parameters:
        fileName - the path of the filename, relative to the Virtual User's data directory
        See Also:
        setMessageBody(String), setMessageBody(byte[])
      • setMessageBody

        public void setMessageBody​(Form form)
        Sets the body of the HTTP request that will be sent to the server, as name/value pairs extracted from the specified Form object. This method is normally used with a POST or PUT request.

        e.g.

        
         // Create a POST request
         Url url33 = new Url(protocol1, localhost, "/cart");
         Request request33 = getWebBrowser().createRequest(HttpMethod.POST, url33, 33);
         
         // Create a new form and populate it with some data 
         Form postData33 = new Form();
         postData33.setCharEncoding("utf-8");   
         postData33.addElement(new InputElement("itemquantity82", "1"));
         postData33.addElement(new InputElement("startcheckout", "startcheckout"));
         
         // attach the form to the POST request and send it
         request33.setMessageBody(postData33);
         Response response33 = request33.send();
         
        Parameters:
        form - the body of the message (e.g. the POST data)
        See Also:
        setMessageBody(String), setMessageBody(byte[]), setMessageBodyFromFile(String)
      • getID

        public int getID()
        Gets the unique ID that has been assigned to this Request. This ID number is created by the WebBrowser. It is the value that is displayed in the web log viewer.
        Returns:
        the unique ID assigned to this Request
      • getMessageBody

        public java.lang.String getMessageBody()
        Gets the body of the HTTP request that will be sent to the server.
        Returns:
        the body of the HTTP request
        See Also:
        setMessageBody(String)
      • getHeaderValue

        public java.lang.String getHeaderValue​(java.lang.String header)
        Gets the value of the specified HTTP request header.
        Parameters:
        header - the header to get the value of
        Returns:
        the value of the header
        See Also:
        setHeader(String, String), removeHeader(String)
      • setHeader

        public void setHeader​(java.lang.String header,
                              java.lang.String value)
        Sets an HTTP header for this Request. The header will be sent to the web server when this Request is sent.

        e.g.

        
         request34.setHeader("X-Requested-With", "XMLHttpRequest");
         
        Parameters:
        header - the header to set
        value - the value to assign to the header
        See Also:
        removeHeader(String), clearHeaders()
      • setHeader

        public void setHeader​(java.lang.String header)
        Sets an HTTP header for this Request. The header will be sent to the web server when this Request is sent.

        e.g.

        
         request34.setHeader("X-Requested-With: XMLHttpRequest");
         
        Parameters:
        header - the header to set, including the value, which should be separated from the name with a colon
        See Also:
        removeHeader(String), clearHeaders()
      • removeHeader

        public void removeHeader​(java.lang.String header)
        Removes an HTTP header from this Request.
        Parameters:
        header - the header to remove
        See Also:
        setHeader(String, String), clearHeaders()
      • containsHeader

        public boolean containsHeader​(java.lang.String header)
        Returns true if this Request contains a particular HTTP header.

        e.g.

        
         if (request.containsHeader("Content-Type"))
         {
             writeMessage(String.format("Content-Type=%s", request.getHeaderValue("Content-Type")));
         }
         
        Parameters:
        header - the HTTP header to check for
        Returns:
        true if this Request contains the specified header
      • getUserAgent

        public java.lang.String getUserAgent()
        Gets the value of the "User-Agent" HTTP header.
        Returns:
        the value of the "User-Agent" HTTP header
      • setUserAgent

        public void setUserAgent​(java.lang.String userAgent)
        Sets the value of the "User-Agent" HTTP header.
        Parameters:
        userAgent - the value to set
      • getReferer

        public java.lang.String getReferer()
        Gets the value of the "Referer" HTTP header.
        Returns:
        the value of the "Referer" HTTP header
      • setReferer

        public void setReferer​(Url url)
        Sets the value of the "Referer" HTTP header.
        Parameters:
        url - the value to set
      • setReferer

        public void setReferer​(java.lang.String referer)
        Sets the value of the "Referer" HTTP header.
        Parameters:
        referer - the value to set
      • unsetReferer

        public void unsetReferer()
        Removes the "Referer" HTTP header.
      • hasReferer

        public boolean hasReferer()
        Returns true if the "Referer" HTTP header has been set for this Request.
        Returns:
        true if the "Referer" header has been set
      • getContentType

        public java.lang.String getContentType()
        Gets the value of the "Content-Type" HTTP header.
        Returns:
        the value of the "Content-Type" HTTP header
      • setContentType

        public void setContentType​(java.lang.String contentType)
        Sets the value of the "Content-Type" HTTP header.
        Parameters:
        contentType - the value to set
      • getHeaderKeys

        public java.util.List<java.lang.String> getHeaderKeys()
                                                       throws com.facilita.exception.InternalError
        Gets a list of names of all the HTTP request headers set in this Request.
        Returns:
        a list of names of all the HTTP request headers set in this Request
        Throws:
        com.facilita.exception.InternalError - an internal error occurred
      • setFollowRedirects

        public void setFollowRedirects​(boolean followRedirects)
        Sets whether redirects will automatically be followed for this Request.

        If the response to this request is an HTTP redirect code (e.g. 301, 302), and this Request object is set to follow redirects, then the eggPlant Performance engine will automatically follow the redirect link. In this case, the Response.wasRedirected() method will return true for the Response object returned by send(), and Response.getRedirectedFrom() will return the Response object containing the HTTP redirect code.

        Default behaviour for newly-created Request objects is to follow redirects, but this can be changed for individual Request objects using this method, or changed on all Request objects using WebBrowser.setDefaultFollowRedirects(boolean).

        Parameters:
        followRedirects - true if redirects should be followed automatically
        See Also:
        send(), Response.wasRedirected(), Response.getRedirectedFrom()
      • getFollowRedirects

        public boolean getFollowRedirects()
        Returns true if redirects will automatically be followed for this Request.

        If the response to this request is an HTTP redirect code (e.g. 301, 302), and this Request object is set to follow redirects, then the eggPlant Performance engine will automatically follow the redirect link. In this case, the Response.wasRedirected() method will return true for the Response object returned by send(), and Response.getRedirectedFrom() will return the Response object containing the HTTP redirect code.

        Default behaviour for newly-created Request objects is to follow redirects, but this can be changed for individual Request objects using setFollowRedirects(boolean), or changed on all Request objects using WebBrowser.setDefaultFollowRedirects(boolean).

        Returns:
        true if redirects will automatically be followed for this Request
      • setRetrieveSubRequests

        public void setRetrieveSubRequests​(boolean getEmbeddedUrls)
        Sets whether sub-requests will be retrieved for this Request. By default, sub-requests are retrieved.
        Parameters:
        getEmbeddedUrls - true if sub-requests should be retrieved
        See Also:
        getRetrieveSubRequests()
      • getRetrieveSubRequests

        public boolean getRetrieveSubRequests()
        Returns true if sub-requests will be retrieved for this Request.
        Returns:
        true if sub-requests will be retrieved for this Request
        See Also:
        setRetrieveSubRequests(boolean)
      • getIncludeQueryDataInLabels

        public boolean getIncludeQueryDataInLabels()
        Returns true if URLs with different query data should be considered different from each other for analysis purposes. If this returns true, then the query data will be included in the HTTP metric labels.

        e.g.

        • http://localhost:32144/search?q=camera
        • http://localhost:32144/search?q=laptop
        It may be important to compare how the query data affects the performance timing data, or you may wish to consider both requests as accessing the same URL under the same label http://localhost:32144/search.
        Returns:
        true if URL query data will be included in the HTTP metric labels
        See Also:
        setIncludeQueryDataInLabels(boolean)
      • setIncludeQueryDataInLabels

        public void setIncludeQueryDataInLabels​(boolean includeQueryDataInLabels)
        Sets whether URLs with different query data should be considered different from each other for analysis purposes. If set to true, then the query data will be included in the HTTP metric labels.

        e.g.

        • http://localhost:32144/search?q=camera
        • http://localhost:32144/search?q=laptop
        It may be important to compare how the query data affects the performance timing data, or you may wish to consider both requests as accessing the same URL under the same label http://localhost:32144/search.
        Parameters:
        includeQueryDataInLabels - true if URL query data should be included in the HTTP metric labels
      • setTimeEveryHttpRequest

        public void setTimeEveryHttpRequest​(boolean timings)
        Sets whether sub-requests should be timed as well as top-level HTTP requests. Top-level requests will always be timed, even if this is set to false.
        Parameters:
        timings - true if sub-requests should be timed as well as top-level HTTP requests
      • getTimeEveryHttpRequest

        public boolean getTimeEveryHttpRequest()
        Returns true if sub-requests will be timed as well as top-level HTTP requests. Top-level requests will always be timed, even if this method returns false.
        Returns:
        true if sub-requests will be timed as well as top-level HTTP requests
      • getSubRequestThreadCount

        public int getSubRequestThreadCount()
        Gets the number of threads that will be used to fetch sub-requests from the web server. If this value is increased, then more sub-requests can be fetched in parallel. However, using more threads will increase the load on the injector machine.
        Returns:
        the number of threads that will be used to fetch sub-requests from the web server
        See Also:
        setSubRequestThreadCount(int)
      • setSubRequestThreadCount

        public void setSubRequestThreadCount​(int subRequestThreadCount)
        Sets the number of threads that will be used to fetch sub-requests from the web server. If this value is increased, then more sub-requests can be fetched in parallel. However, using more threads will increase the load on the injector machine.
        Parameters:
        subRequestThreadCount - the number of threads that will be used to fetch sub-requests from the web server
      • getVersion

        public java.lang.String getVersion()
        Gets the HTTP version as a String.

        The version of HTTP in common use is currently "HTTP/1.1", but "HTTP/2" can be used to enable HTTP/2 support where applicable.

        Returns:
        the HTTP version
        See Also:
        setVersion(String)
      • setVersion

        public void setVersion​(java.lang.String version)
        Sets the HTTP version.

        The version of HTTP in common use is currently "HTTP/1.1", but "HTTP/2" can be used to enable HTTP/2 support where applicable.

        Parameters:
        version - the HTTP version to use
        See Also:
        getVersion()
      • getChunkSize

        public int getChunkSize()
        Gets the size in bytes of the chunk size to use when sending data using Transfer-Encoding: chunked
        Returns:
        the size in bytes of the chunk size to use when sending data using Transfer-Encoding: chunked
        See Also:
        setChunkSize(int)
      • setChunkSize

        public void setChunkSize​(int chunkSize)
        Sets the size in bytes of the chunk size to use when sending data using Transfer-Encoding: chunked
        Parameters:
        chunkSize - the size in bytes of the chunk size to use when sending data using Transfer-Encoding: chunked
        See Also:
        getChunkSize()
      • setKeepAllSubRequestContent

        public void setKeepAllSubRequestContent​(boolean keep)
        Sets whether the content of responses to sub-requests should be kept.

        If this is set to false, then all the responses to sub-requests will be discarded. There is a significant performance penalty to keep the sub-request content, so this value should only be set to true if it is necessary to examine the content of sub-responses.

        Parameters:
        keep - true if the content of responses to sub-requests should be kept
        See Also:
        getKeepAllSubRequestContent(), setKeepContent(boolean), addKeepSubRequestContentType(String), addKeepSubRequestContentUrl(String)
      • setKeepContent

        public void setKeepContent​(boolean keep)
        Sets whether to keep the content of responses.

        If this value is set to false then the content of every response to this Request will be discarded, and it will not be possible to examine the content using the Response class (but other information will still be accessible in the Response objects).

        Parameters:
        keep - true if the content of responses should be kept
        See Also:
        getKeepContent(), setKeepAllSubRequestContent(boolean)
      • addKeepSubRequestContentType

        public void addKeepSubRequestContentType​(java.lang.String typeFragment)
        Adds a Content-Type fragment, so the content of sub-request responses that match the specified Content-Type fragment will be kept.

        In general, it is not necessary to retain content for sub-requests, and it will incur a performance penalty to do so. However, a situation may arise where it is necessary to check or extract a value from a sub-response. In this situation, you can specify that the content of certain sub-responses should be retained.

        e.g.

        
         // Keep the content of any sub-requests that have a Content-Type starting with "text" (e.g. text/html, text/xml)
         request.addKeepSubRequestContentType("text");
         
        Parameters:
        typeFragment - sub-request responses that have a Content-Type header containing this typeFragment will be kept
        See Also:
        getKeepContent(), getKeepAllSubRequestContent(), removeKeepSubRequestContentType(String), addKeepSubRequestContentUrl(String)
      • addKeepSubRequestContentUrl

        public void addKeepSubRequestContentUrl​(java.lang.String urlFragment)
        Adds a URL, so the content of sub-request responses that match the specified URL fragment will be kept.

        In general, it is not necessary to retain content for sub-requests, and it will incur a performance penalty to do so. However, a situation may arise where it is necessary to check or extract a value from a sub-response. In this situation, you can specify that the content of certain sub-responses should be retained.

        e.g.

        
         // Keep the content of the sub-request with the url http://localhost/images/magnifying-glass.png
         request.addKeepSubRequestContentUrl("http://localhost/images/magnifying-glass.png");
         
        Parameters:
        urlFragment - the responses from sub-requests that match this urlFragment will be kept
        See Also:
        getKeepContent(), getKeepAllSubRequestContent(), removeKeepSubRequestContentUrl(String), addKeepSubRequestContentType(String)
      • removeKeepSubRequestContentType

        public void removeKeepSubRequestContentType​(java.lang.String typeFragment)
        Removes a Content-Type fragment, so the content of sub-request responses that match the specified Content-Type fragment will no longer be kept.

        In general, it is not necessary to retain content for sub-requests, and it will incur a performance penalty to do so. However, a situation may arise where it is necessary to check or extract a value from a sub-response. In this situation, you can specify that the content of certain sub-responses should be retained.

        e.g.

        
         // Don't keep the content of any sub-requests that have a Content-Type starting with "text" (e.g. text/html, text/xml)
         request.removeKeepSubRequestContentType("text");
         
        Parameters:
        typeFragment - sub-request responses that have a Content-Type header containing this typeFragment will no longer be kept
        See Also:
        addKeepSubRequestContentType(String), setKeepAllSubRequestContent(boolean)
      • removeKeepSubRequestContentUrl

        public void removeKeepSubRequestContentUrl​(java.lang.String urlFragment)
        Removes a URL, so the content of sub-request responses that match the specified URL fragment will no longer be kept.

        In general, it is not necessary to retain content for sub-requests, and it will incur a performance penalty to do so. However, a situation may arise where it is necessary to check or extract a value from a sub-response. In this situation, you can specify that the content of a particular sub-responses should be retained.

        e.g.

        
         // Don't keep the content of the sub-request with the url http://localhost/images/magnifying-glass.png
         request.removeKeepSubRequestContentUrl("http://localhost/images/magnifying-glass.png");
         
        Parameters:
        urlFragment - the responses from sub-requests that match this urlFragment will no longer be kept
        See Also:
        getKeepContent(), getKeepAllSubRequestContent(), addKeepSubRequestContentUrl(String)
      • getContentUrlFragments

        public java.util.List<java.lang.String> getContentUrlFragments()
                                                                throws com.facilita.exception.InternalError
        Gets a list of all the URL fragments for which the content of sub-request responses will be kept.
        Returns:
        a list of all the URL fragments for which the content of sub-request responses will be kept
        Throws:
        com.facilita.exception.InternalError - an internal error occurred
        See Also:
        addKeepSubRequestContentUrl(String), removeKeepSubRequestContentUrl(String)
      • getContentTypeFragments

        public java.util.List<java.lang.String> getContentTypeFragments()
                                                                 throws com.facilita.exception.InternalError
        Gets a list of all the Content-Type fragments for which the content of sub-request responses will be kept.
        Returns:
        a list of all the Content-Type fragments for which the content of sub-request responses will be kept
        Throws:
        com.facilita.exception.InternalError - an internal error occurred
        See Also:
        addKeepSubRequestContentType(String), removeKeepSubRequestContentType(String)
      • isDynatraceIntegrationEnabled

        public boolean isDynatraceIntegrationEnabled()
        Returns true if dynaTrace integration is enabled. When dynaTrace integration is enabled, a special dynaTrace HTTP header is sent with each HTTP request.
        Returns:
        true if dynaTrace integration is enabled
        See Also:
        setDynatraceIntegrationEnabled(boolean)
      • setDynatraceIntegrationEnabled

        public void setDynatraceIntegrationEnabled​(boolean value)
        Sets whether or not dynaTrace integration is enabled. When dynaTrace integration is enabled, a special dynaTrace HTTP header is sent with each HTTP request.
        Parameters:
        value - true to enable dynaTrace integration, false to disable it
        See Also:
        isDynatraceIntegrationEnabled()
      • getCharactersAllowedInPostedForm

        public java.lang.String getCharactersAllowedInPostedForm()
        Gets the characters that will NOT be percent-encoded when a Form is sent to the web server using a POST request.

        By default, a character will be percent-encoded within a form if it is:

        • Outside the ASCII range OR
        • Not an alpha-numeric character AND not in this list of allowed characters
        By default, the allowed list of characters is as follows:
        • ' ' - space
        • '-' - hyphen
        • '_' - underscore
        • '.' - full stop
        • '*' - asterisk
        Returns:
        the characters that will not be encoded
        See Also:
        setCharactersAllowedInPostedForm(String), setMessageBody(Form), Coder.getDefaultCharactersAllowedInPostedForm()
      • setCharactersAllowedInPostedForm

        public void setCharactersAllowedInPostedForm​(java.lang.String charactersAllowedInPostedForm)
        Sets the characters that will NOT be percent-encoded when a Form is sent to the web server using a POST request.

        By default, a character will be percent-encoded within a form if it is:

        • Outside the ASCII range OR
        • Not an alpha-numeric character AND not in this list of allowed characters
        By default, the allowed list of characters is as follows:
        • ' ' - space
        • '-' - hyphen
        • '_' - underscore
        • '.' - full stop
        • '*' - asterisk
        Parameters:
        charactersAllowedInPostedForm - the list of characters not to percent-encode
        See Also:
        getCharactersAllowedInPostedForm(), setMessageBody(Form), Coder.getDefaultCharactersAllowedInPostedForm()
      • getHttpStatusCategory

        public HttpStatusCategory getHttpStatusCategory​(HttpStatus status)
                                                 throws BadValueException
        Returns the registered status category for the given HTTP status. Since all HTTP codes categories can be overwritten to reflect your server behaviour, it can be useful to establish what is the current registered category.
        Parameters:
        status - Object of class HttpStatus representing an HTTP status code.
        Returns:
        HttpStatusCategory
        Throws:
        BadValueException - An error occurred
      • setHttpStatusCategory

        public void setHttpStatusCategory​(HttpStatus status,
                                          HttpStatusCategory category)
        Registers the provided HTTP status code range against the predefined category. All HTTP codes categories can be overwritten to reflect your server behaviour, it will affect how they get reported during the test run (errors, warnings or no report).
        Parameters:
        status - Object of class HttpStatus representing an HTTP status code.
        category - One of the enumeration HttpStatusCategory
      • setHttpStatusCategory

        public void setHttpStatusCategory​(HttpStatusRange statusRange,
                                          HttpStatusCategory category)
        Registers the provided HTTP status code range against the predefined category. All HTTP codes categories can be overwritten to reflect your server behaviour, it will affect how they get reported during the test run (errors, warnings or no report).
        Parameters:
        statusRange - One of the enumeration HttpStatusRange representing an HTTP status code ranges.
        category - One of the enumeration HttpStatusCategory