User Tools

Site Tools


user-guide:additional_interfaces:http

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
user-guide:additional_interfaces:http [2025/01/17 12:34] – [RGG interaction] Timuser-guide:additional_interfaces:http [2025/01/22 15:47] (current) – [HTTP server user guide] Tim
Line 1: Line 1:
-====== HTTP server user guide ======+====== HTTP server ======
  
 It is possible to start GroIMP as a HTTP server to then send model paths via HTTP for GroIMP to execute. After GroIMP executed the model values can be returned to the HTTP client who send the request. It is possible to send several models in series or in parallel.  It is possible to start GroIMP as a HTTP server to then send model paths via HTTP for GroIMP to execute. After GroIMP executed the model values can be returned to the HTTP client who send the request. It is possible to send several models in series or in parallel. 
 +
 +
 +<uml>@startuml
 +hide footbox
 +title HTTP server
 +
 +User -> GroIMP: Start GroIMP
 +User -> GroIMP: Send Model-path
 +GroIMP -> User: Return result
 +User -> GroIMP: Close GroIMP
 +
 +@enduml</uml>
 ===== Execution ===== ===== Execution =====
  
Line 62: Line 74:
 </code> </code>
  
 +Using the HttpResponse open access to several functions, a full list can be found [[https://javadoc.grogra.de/imp/de/grogra/imp/net/HttpResponse.html|here]]. The most important once are listed below:
  
 +=== setContent ===
  
 +The setContent function defines what is responded to the client after the send command is executed.
 +To proper define this the mimeType (what kind of data is it) and the content must be provided. The content can be provided as a byte array or as encoded text using two strings, one for text and one for the encoding (most likely UTF-8).
 +
 +
 +=== Send ===
 +
 +Executing the send command sends the HttpResponse to the client. A boolean parameter defines if possible content should be returned.
 +
 +If needed it is also possible to add a HTTP response code to and a reason for the code as parameters, to have a more clear communication with the client. 
 +
 +
 +=== sendBadRequest ===
 +
 +This is mainly a wrapper for the send command to notify the client that something went wrong and the request cant be handled.
 +
 +
 +=== getRequest ===
 +
 +This function gives the project access to the request of the user (the specification of the class can be found [[https://javadoc.grogra.de/utilities/de/grogra/http/Request.html | here]]).
 +
 +Using this request object, it is possible to access the original query with getQuery() which 
 +provides the last section of the URL or the getContent() function which returns the body of the request as a byte array that then can be handled as needed.
 +
 +  
 +
 +==== Multi-use Model ====
 +
 +Using the HttpResponse.get function will return null if the model was not opened with a http server. Therefore this can be used to ensure that the predefined simulation is not starting automatically if the model was opened with the GUI for modelling.
  
 ===== Options ===== ===== Options =====
Line 77: Line 119:
 In the subsection Open HTTP server the default port which is suggested by the gui dialog can be defined. This might be useful for a setup where the original default port is often occupied. In the subsection Open HTTP server the default port which is suggested by the gui dialog can be defined. This might be useful for a setup where the original default port is often occupied.
      
-===== Server-Port =====+===== Tutorials ===== 
 + 
 +  * [[:tutorials:http_server|Start a http model]] 
 + 
 + 
 + 
 +===== *Server-Port =====
  
 A port on a computer is used to define which application is actually meant by a network request. A port on a computer is used to define which application is actually meant by a network request.
user-guide/additional_interfaces/http.1737113676.txt.gz · Last modified: 2025/01/17 12:34 by Tim