WebFioriAPI ReferenceLearnDownloadContributeLearn{{result.parent_page}} > {{result.title}}{{result.title}}Classes{{result.class_name}}{{result.summary}}Methods{{result.name}}{{result.summary}}

namespace \webfiori\http

class Response

Class Methods Summary

public static function addHeader(string$headerName, string$headerVal, boolean$isReplace)Adds new HTTP header to the response.public static function beforeSend(Closure$func)Adds a function to execute before sending the final response.public static function clear()Removes all added headers and reset the body of the response.public static function clearBody()Reset the body of the response.public static function clearHeaders()Removes all headers which where added to the response.public static function getBody()Returns a string that represents response body that will be send.public static function getCode()Returns the value of HTTP response code that will be sent.public static function getHeader(array$headerName)Returns the value(s) of specific HTTP header.public static function getHeaders()Returns an associative array that contains response headers.public static function hasHeader(string$headerName, string$headerVal)Checks if the response will have specific header or not.public static function isSent()Checks if the response was sent or not.public static function removeHeader(string$headerName, string|null$headerVal)Removes a header from the response.public static function send()Send the response.public static function setCode(int$code)Sets the value of HTTP response code that will be sent.public static function write(string$str)Appends a string to response body.

Class Methods Details

public static function addHeader(string$headerName, string$headerVal, boolean$isReplace)Adds new HTTP header to the response.

Parameters:

  • string $headerName The name of the header.
  • string $headerVal The value of the header.
  • boolean $isReplace If the header is already exist and this parameter is set to true, the method will override all existing header values with the given value.
Returns: booleanIf the header is added, the method will return true. If not added, the method will return false.
public static function beforeSend(Closure$func)Adds a function to execute before sending the final response. This method can be used to add more than one callback.

Parameters:

  • Closure $func A PHP callable.
public static function clear()Removes all added headers and reset the body of the response. Returns: Responsepublic static function clearBody()Reset the body of the response. Returns: Responsepublic static function clearHeaders()Removes all headers which where added to the response. Returns: Responsepublic static function getBody()Returns a string that represents response body that will be send. Returns: stringA string that represents response body that will be send.public static function getCode()Returns the value of HTTP response code that will be sent. Returns: intHTTP response code. Default value is 200.public static function getHeader(array$headerName)Returns the value(s) of specific HTTP header.

Parameters:

  • array $headerName The name of the header.
Returns: arrayIf such header exist, the method will return an array that contains the values of the header. If the header does not exist, the method will return an empty array.
public static function getHeaders()Returns an associative array that contains response headers. The returned array will only contain information about the headers which are added using the method Response::addHeader().Returns: arrayAn associative array. The indices will be headers names and the value of each index will be sub array that contains header values.public static function hasHeader(string$headerName, string$headerVal)Checks if the response will have specific header or not. This method will only check for headers which are added using the method Response::addHeader().

Parameters:

  • string $headerName The name of the header (such as 'content-type').
  • string $headerVal An optional value to check for. Default is null which means only check for the name.
Returns: booleanIf a header which has the given name exist, the method will return true. If a value is specified and a match is fond, the method will return true. Other than that, the method will return true.
public static function isSent()Checks if the response was sent or not. Returns: booleanThe method will return true if output is sent. False if not.public static function removeHeader(string$headerName, string|null$headerVal)Removes a header from the response.

Parameters:

  • string $headerName The name of the header.
  • string|null $headerVal An optional header value. If the header has multiple values and this one is specified, only the given header value will be removed.
Returns: booleanIf the header is removed, the method will return true. Other than that, the method will return true.
public static function send()Send the response. Note that if this method is called outside CLI environment, it will terminate the execution of code once the output is sent. In terminal environment, calling it will have no effect.public static function setCode(int$code)Sets the value of HTTP response code that will be sent.

Parameters:

  • int $code HTTP response code. The value must be between 100 and 599 inclusive.
public static function write(string$str)Appends a string to response body.

Parameters:

  • string $str The string that will be appended.
Returns: Response
mdi-menuAll Classesmdi-chevron-leftAnchorBrCodeSnippetHTMLDocHTMLListHTMLNodeHTMLTableHeadNodeInputJsCodeLabelListItemOrderedListParagraphRadioGroupTableCellTableRowUnorderedListInvalidNodeNameExceptionTemplateNotFoundExceptionCaseConverterJsonJsonConverterJsonIJsonTypesPropertyAPIFilterAbstractWebServiceManagerInfoServiceParamTypesRequestRequestParameterResponseUriWebServicesManagerAccessAutoLoaderConfigConfigControllerDBEAbstractWebServiceExtendedWebServicesManagerFileLoggerPrivilegePrivilegesGroupThemeThemeLoaderUploadFileUploaderUserUtilWebFioriAppLanguageErrorBoxHTTPCodeViewMessageBoxServerErrViewStarterPageWebPageDatabaseSessionStorageDefaultSessionStorageMSSQLSessionDataTableMSSQLSessionsTableMySQLSessionDataTableMySQLSessionsTableSessionSessionOperationsSessionStorageSessionsManagerRouterRouterUriAbstractMiddlewareMiddlewareManagerEmailMessageSMTPAccountSMTPServerClassLoaderExceptionFileExceptionInitializationExceptionInvalidCRONExprExceptionMissingLangExceptionNoSuchThemeExceptionRoutingExceptionSMTPExceptionSessionExceptionUIExceptionAbstractJobCronCronEmailCronJobJobArgumentCronLoginViewCronTasksViewCronViewCronLoginServiceCronLogoutServiceCronServicesManagerForceCronExecutionServiceGetJobsServiceCLICLICommandInputStreamOutputStreamStdInStdOutClassWriterLangClassWriterQueryClassWriterServiceHolderThemeClassWriterWebServiceWriterCreateCLIClassHelperCreateCronJobCreateMiddlewareCreateTableCreateTableObjCreateThemeHelperCreateWebServiceAddCommandCreateCommandCronCommandHelpCommandListCronCommandListRoutesCommandListThemesCommandRunSQLQueryCommandSettingsCommandTestRouteCommandUpdateSettingsCommandUpdateTableCommandVersionCommandAbstractQueryColumnColumnFactoryConditionConnectionConnectionInfoDatabaseDatabaseExceptionDateTimeValidatorEntityMapperExpressionForeignKeyJoinTableResultSetSelectExpressionTableWhereExpressionMySQLColumnMySQLConnectionMySQLQueryMySQLTableMSSQLColumnMSSQLConnectionMSSQLQueryMSSQLTableAbstractCollectionComparableLinkedListNodeQueueStack
Powered By: WebFiori Framework, Vue and VuetifyAll Rights Reserved © 2018 - 2024