blob: 3892ac0d0c7b52123fc8f82174107472ee53438d [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2000-2019 Ericsson Telecom AB //
// //
// All rights reserved. This program and the accompanying materials //
// are made available under the terms of the Eclipse Public License v2.0 //
// which accompanies this distribution, and is available at //
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Module: EPTF_CLL_DsRestAPI_HTTPServer_Definitions
//
// Purpose:
// This module contains definitions of EPTF_CLL_DsRestAPI_HTTPServer.
//
// Module depends on:
// <IPL4asp_Types>
// <IPL4asp_PortType>
// <EPTF_CLL_Base_Definitions>
// <EPTF_CLL_DsRestAPI_DSServer_Definitions>
// <EPTF_CLL_Common_Definitions>
//
// Current Owner:
// Tamas Kis (ekistam)
//
// Last Review Date:
// -
//
// Detailed Comments:
// The HTTP server supports the following HTTP methods:
// - GET - method used for getting files (standard GET method)
// - HEAD - standard HEAD method
// - POST - standard POST method (used in the REST API)
// - PUT - methd used to save files (standard PUT method)
// - LSDIR - method used to get the contents of a directory
// - MKDIR - method used to create a directory
// - RMDIR - method used to delete directories or files
//
///////////////////////////////////////////////////////////////
module EPTF_CLL_DsRestAPI_HTTPServer_Definitions
{
import from IPL4asp_Types all;
import from IPL4asp_PortType all;
import from EPTF_CLL_Base_Definitions all;
import from EPTF_CLL_DsRestAPI_DSServer_Definitions all;
import from EPTF_CLL_Common_Definitions all;
friend module EPTF_CLL_DsRestAPI_HTTPServer_Functions;
private const charstring cg_EPTF_DsRestAPI_HTTPServer_mainHtml := "/Main.html";
friend const charstring cg_EPTF_DsRestAPI_Browser_chunk_FromConnId_HashMapName := "EPTF_DsRestAPI_Browser_chunk_FromConnId_HashMapName"
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_GET := "GET";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HEAD := "HEAD";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_POST := "POST";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_PUT := "PUT";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_LSDIR := "LSDIR";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_MKDIR := "MKDIR";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_RMDIR := "RMDIR";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_OPTIONS := "OPTIONS";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_SP := " ";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_FS := ":";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_Dot := ".";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_Slash := "/";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF := "\r\n";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLFCRLF := "\r\n\r\n";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_HTTP10VER := "HTTP/1.0";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_HTTP11VER := "HTTP/1.1";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_ServerHdr := "Server: EPTF_CLL_DsRestAPI";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_ContentLength_Name := "Content-Length";
friend const charstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_ContentType_Name := "Content-Type";
friend const octetstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_Dot_oct := '2E'O;
friend const octetstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF_oct := '0D0A'O;
friend const octetstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLFCRLF_oct := '0D0A0D0A'O;
friend const octetstring cg_EPTF_DsRestAPI_HTTPServer_HTTP_ContentLength_Name_oct := '436f6E74656E742d4C656E677468'O;
friend const charstring cg_EPTF_DsRestAPI_CORSAccessHeaders := "Access-Control-Allow-Origin: *"
& cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF
& "Access-Control-Allow-Methods: GET, HEAD, POST, PUT"
& cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF
& "Access-Control-Allow-Credentials: true"
& cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF
& "Access-Control-Allow-Headers: Accept, Accept-Encoding, Accept-Language, Allow, Connection, Content-Type, Origin, Referer, User-Agent"
& cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF
& "Access-Control-Expose-Headers: Content-Length, Content-Type, Server";
friend const charstring cg_EPTF_DsRestAPI_HTTPHeaderChunk01 := cg_EPTF_DsRestAPI_HTTPServer_HTTP_HTTP11VER & cg_EPTF_DsRestAPI_HTTPServer_HTTP_SP;
friend const charstring cg_EPTF_DsRestAPI_HTTPHeaderChunk02 := cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF & cg_EPTF_DsRestAPI_HTTPServer_HTTP_ContentLength_Name & cg_EPTF_DsRestAPI_HTTPServer_HTTP_FS & cg_EPTF_DsRestAPI_HTTPServer_HTTP_SP;
friend const charstring cg_EPTF_DsRestAPI_HTTPHeaderChunk03 := cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF & cg_EPTF_DsRestAPI_HTTPServer_HTTP_ContentType_Name & cg_EPTF_DsRestAPI_HTTPServer_HTTP_FS & cg_EPTF_DsRestAPI_HTTPServer_HTTP_SP;
friend const charstring cg_EPTF_DsRestAPI_HTTPHeaderChunk04 := cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF & cg_EPTF_DsRestAPI_HTTPServer_HTTP_ServerHdr & cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF & cg_EPTF_DsRestAPI_CORSAccessHeaders & cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF & cg_EPTF_DsRestAPI_HTTPServer_HTTP_CRLF;
/////////////////////////////////////////////////////////////////////////////
// Type: EPTF_DsRestAPI_HTTPServer_CT
//
// Purpose:
// The HTTP Server UI Model component
//
// Extensions:
// EPTF_Base_CT, EPTF_DsRestAPI_DSServer_CT
//
// Variables:
// - v_DsRestAPI_HTTPServer_initialized - *boolean* - represents if HTTP Server is initialized
// - v_DsRestAPI_HTTPServer_mainHandler - *default* - main handler default altstep
// - v_EPTF_DsRestAPI_HTTPServer_directory - *charstring* - directory of HTTP Server
// - v_EPTF_DsRestAPI_HTTPServer_path - *charstring* - path to HTTP Server
// - v_EPTF_DsRestAPI_HTTPServer_mainHtml - *charstring* - path to main page
// - v_EPTF_DsRestAPI_Browser_chunk - <EPTF_OctetstringList> - browser chunk
// - v_EPTF_DsRestAPI_Browser_chunk_FromConnId_Hash - *integer* - hash for browser chunk
// - v_EPTF_DsRestAPI_Browser_chunk_FromConnId_Queue - *integer* - queue of browser chunk
// - v_DsRestAPI_HTTPServer_IPL4_PCO_PT - <IPL4asp_PT> - port to send HTTP messages
// - v_ConnId - <ConnectionId> - connection id of DsRestAPI HTTP server
//
// Ports:
// -
// Function types:
// -
//
// Detailed Comments:
// -
/////////////////////////////////////////////////////////////////////////////
type component EPTF_DsRestAPI_HTTPServer_CT extends EPTF_Base_CT, EPTF_DsRestAPI_DSServer_CT
{
private var boolean v_DsRestAPI_HTTPServer_initialized := false;
private var default v_DsRestAPI_HTTPServer_mainHandler := null;
private var charstring v_EPTF_DsRestAPI_HTTPServer_directory;
private var charstring v_EPTF_DsRestAPI_HTTPServer_path;
private var charstring v_EPTF_DsRestAPI_HTTPServer_mainHtml := cg_EPTF_DsRestAPI_HTTPServer_mainHtml;
private var EPTF_OctetstringList v_EPTF_DsRestAPI_Browser_chunk := {};
private var integer v_EPTF_DsRestAPI_Browser_chunk_FromConnId_Hash := -1;
private var integer v_EPTF_DsRestAPI_Browser_chunk_FromConnId_Queue := -1;
private var integer v_EPTF_DsRestAPI_Browser_Buffer_FBQ := -1;
private var EPTF_DsRestAPI_HTTPServer_ListOfMessages v_EPTF_DsRestAPI_Browser_Buffer_Messages := {};
private var boolean v_EPTF_DsRestAPI_Browser_Buffer_dropAll := true;
private var integer v_EPTF_DsRestAPI_Browser_Buffer_maxSize := 20;
private port IPL4asp_PT v_DsRestAPI_HTTPServer_IPL4_PCO_PT;
private var ConnectionId v_EPTF_DsRestAPI_HTTPServer_connId := -1;
private timer t_bufferTimer := 0.0;
}
friend type record EPTF_DsRestAPI_HTTPServer_BufferItem {
octetstring request,
integer connId
}
friend type record of EPTF_DsRestAPI_HTTPServer_BufferItem EPTF_DsRestAPI_HTTPServer_ListOfMessages;
///////////////////////////////////////////////////////////////////////////////
// Type: EPTF_DsRestAPI_HTTPServer_FileInfo
//
// Purpose:
// Type for HTTP Server File Info
//
// Elements:
// - fileName - *charstring* - the name of the file
// - contentType - *charstring* - the type of content
// - size - *charstring* - the size of the file
// - timestamp - *charstring* - the timestamp of the file
//
///////////////////////////////////////////////////////////////////////////////
friend type record EPTF_DsRestAPI_HTTPServer_FileInfo {
charstring fileName,
charstring contentType,
integer size,
integer timestamp
} with {
variant(fileName) "JSON:name as fileName";
variant(contentType) "JSON:name as contentType";
variant(size) "JSON:name as size";
variant(timestamp) "JSON:name as timestamp";
}
///////////////////////////////////////////////////////////
// Type: EPTF_DsRestAPI_HTTPServer_FileInfoList
//
// Purpose:
// Type for storing list of <EPTF_DsRestAPI_HTTPServer_FileInfo> items
//
// Elements:
// <EPTF_DsRestAPI_HTTPServer_FileInfo>
///////////////////////////////////////////////////////////
friend type record of EPTF_DsRestAPI_HTTPServer_FileInfo EPTF_DsRestAPI_HTTPServer_FileInfoList;
///////////////////////////////////////////////////////////////////////////////
// Type: EPTF_DsRestAPI_HTTPServer_FileInfoList_Wrapper
//
// Purpose:
// Type for wrapping file info lists
//
// Elements:
// - fileList - <EPTF_DsRestAPI_HTTPServer_FileInfoList> - list of file info
//
///////////////////////////////////////////////////////////////////////////////
friend type record EPTF_DsRestAPI_HTTPServer_FileInfoList_Wrapper {
EPTF_DsRestAPI_HTTPServer_FileInfoList fileList
} with { variant(fileList) "JSON: name as fileList"; }
} // ~ module EPTF_DsRestAPI_HTTPServer_Definitions