Use Request.InputStream with POST method where Request is ServletRequest
B4X:
Public Sub PostStreamBytes As HttpResponseMessage
Try
Dim tmp As String = File.Combine(Main.srvr.StaticFilesFolder, "tmp")
Dim ins As InputStream = Request.InputStream
Dim out As OutputStream = File.OpenOutput(tmp, "upload.pdf", False)
File.Copy2(ins, out)
out.Close
HRM.ResponseCode = 200
Catch
Log(LastException)
HRM.ResponseCode = 400
HRM.ResponseError = "Error Input Stream"
End Try
Return HRM
End Sub
Thank you very much. But unfortunately in the "B4a Http Server 1.0" library the jetty 7 webserver is used, which does not support the ServletRequest.InputStream method
What alternatives would you propose to receive the data in post?
We currently retrieve the name of the file that was sent and then retrieve it from the web server's temporary files.
B4X:
Dim sNameFileUploated As String = Request.GetUploadedFile(<key_name_fields_uploaded>)
'open the temporary file.
Dim oInputStream As InputStream
oInputStream = File.OpenInput(serverHTTP.TempFolder, sNameFileUploated)
The HttpServer library is a new library, based on an open source project named Jetty. This library allows you to easily embed an Http server in your application. Http server means that you can point a browser to the device IP address (and relevant port) and communicate with your app. It can be...
HttpServer was built before B4J was available and especially before jServer was available. Real servers should be built with jServer.
I don't recommend using HttpServer.
It is a personal project of mine that I started as a hobby on B4i and it has become an interesting project, so that I have modified it to be multiplatform. It is an http server, which allows a browser to navigate on html pages stored on the device. In addition, dynamic pages can also be...
The HttpServer library is a new library, based on an open source project named Jetty. This library allows you to easily embed an Http server in your application. Http server means that you can point a browser to the device IP address (and relevant port) and communicate with your app. It can be...
It is a personal project of mine that I started as a hobby on B4i and it has become an interesting project, so that I have modified it to be multiplatform. It is an http server, which allows a browser to navigate on html pages stored on the device. In addition, dynamic pages can also be...
The HttpServer library is a new library, based on an open source project named Jetty. This library allows you to easily embed an Http server in your application. Http server means that you can point a browser to the device IP address (and relevant port) and communicate with your app. It can be...
It is a personal project of mine that I started as a hobby on B4i and it has become an interesting project, so that I have modified it to be multiplatform. It is an http server, which allows a browser to navigate on html pages stored on the device. In addition, dynamic pages can also be...
Hi, I am using the HttpServer library to communicate with a web application, I would like to know how to use the Https protocol with an SSLcertificate. Raffaele
www.b4x.com
Exposes the following methods for the "ServletRequest" class
Java:
//Returns the HTTP method (GET or POST).
public String getMethod()
// Returns the request URL without the host and any parameters.
public String getRequestURI()
// Returns the client IP address.
public String getRemoteAddress()
// Returns the parameter value or an empty string if the parameter does not exist.
public String GetParameter(String Name)
// Returns the name of the temporary file that was uploaded to Server.TempFolder.
public String GetUploadedFile(String Key)
Is the compatibility of the "HttpServer" library with the new "jServer" libraries supported, in your opinion?
Sorry, I couldn't answer your question as I am not familiar with both libraries.
Try to ask @Erel and @Star-Dust
Please start a new thread and explain more details.
I am confused since your initial question seems was about client's side httpjob in the title but you are asking about server's side httpserver class which is a different topic.