B4i Library SD: iHttpServer (beta)

Star-Dust

Expert
Licensed User
Longtime User
app still crashes with v0.67 in release mode when uploading a file.
The 0.67 has a further bug that occurs with very large files. The next release corrects it, at least with the texts that I have completed these days.
The next release will not be released in the next ones as we are adding new features that need to be tested thoroughly.
 

Star-Dust

Expert
Licensed User
Longtime User
app still crashes with v0.67 in release mode when uploading a file.
It often happens if you start a new upload on the same connection, when the previous one has not yet completed.

In the next version there will be events that will be raised with each upload and completion. Additionally, progression will also raise an event.

This will help avoid these problems.
 

ilan

Expert
Licensed User
Longtime User

it happend to me in the first upload.
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.68
  • Several issues have been fixed. Now it is possible to upload also in release version without problems.
  • Events have been added that indicate when an UpLoad is complete.
  • Update Example
Tip: Save all files in compressed format and unzip at startup in the Temporary folder. Avoid reading directly from DirAssets many problems could arise.
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel. 0.69
  • update event: UploadedFile (req As ServletRequest, resp As ServletResponse)
  • update example
_______________________________________________________________________________________________________________________________

This is the new example run in release mode. After uploading the image resend it as a reply on the next page


On the server side (in this case an iPhone6) in the example it will show a preview of the upload
 
Last edited:

ilan

Expert
Licensed User
Longtime User
i can confirm that it works now after making few tests (will need to make more)
i did encounter 1 issue. after uploading the webbrowser url is changing to http://10.0.0.14:51051/filehelper
what means that clicking on the url will get a a 404 Error:



is there a redirect method to catch the post request at the filehelper url?
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
i can confirm that it works know after making few tests (will need to make more)
It took a lot of work

No I believe it from code if I don't find a file in the indicated folder. I'll check it out
 

Star-Dust

Expert
Licensed User
Longtime User
is there a redirect method to catch the post request at the filehelper url?
vYou can intercept and redirect from the Handle event, see the example below
B4X:
Private Sub Svr_Handle(req As ServletRequest, resp As ServletResponse)
    Dim fn As String = req.GetRequestURI.ToLowerCase
    Log("Request URI: " & fn)
    
    Select req.GetMethod
        Case "GET"
            If fn = "/" Then fn = "/index.html"
            If File.Exists(File.DirTemp,fn ) Then
                ' other file
                resp.SendFile(File.DirTemp,fn )
            Else if req.GetRequestURI="/FormExampleHelper" Then
                FormExampleHelper(req ,resp)
                '  or
                ' resp.SendFile(File.DirTemp,"myfile.html")
            Else
                'not found
                resp.SendNotFound(fn)
            End If
        Case "POST"
         
    End Select
End Sub
 

ilan

Expert
Licensed User
Longtime User
actually, this is what i do now:

B4X:
'...
If req.GetRequestURI="/" Or req.GetRequestURI="/filehelper" Then
'...
 

Star-Dust

Expert
Licensed User
Longtime User
actually, this is what i do now:

B4X:
'...
If req.GetRequestURI="/" Or req.GetRequestURI="/filehelper" Then
'...
So both the start page and the helper page directs you to one place
 

Star-Dust

Expert
Licensed User
Longtime User
Yes, this is a workaround.
You can also use the SendRedirect method
B4X:
if req.GetRequestURI="/FormExampleHelper" Then svr.SendRedirect("http://www.myredirect.com/mypage.html")
It depends what you need to do. The roads are many
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.72

I am happy to present the first version which includes WebSocket and QueryElement. I added an example (post#1) to understand how to use Query Element based on an existing example for B4J (this ServerExampleNoMySQL.)

 

Waldemar Lima

Well-Known Member
Licensed User
B4X:
B4i Version: 7.20
Parsing code.    (0.00s)
Building folders structure.    (0.05s)
Compiling code.    (0.01s)
Compiling layouts code.    (0.00s)
Compiling debugger engine code.    (0.02s)
Building Xcode project.    (0.22s)
Preparing project for builder.    (0.03s)
    Project size: 0.16 MB
Sending data to remote compiler.    Error
B4i line: 33
Private Svr As httpServer
unknown receiver 'b4i_httpserver'; did you mean 'b4i_server'?

Out: Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -configuration Release PRODUCT_NAME=HttpServer CONFIGURATION_BUILD_DIR=/Users/administrator/Documents/UploadedProjects/<user id>/Payload "CODE_SIGN_IDENTITY=iPhone Distribution: xxxxxx" "OTHER_CODE_SIGN_FLAGS=--keychain <user id>" PROVISIONING_PROFILE=d3f9e6ea-9623-4c4a-94a6-d2d721c9a402 -arch arm64

Build settings from command line:
    ARCHS = arm64
    CODE_SIGN_IDENTITY = iPhone Distribution: xxx
    CONFIGURATION_BUILD_DIR = /Users/administrator/Documents/UploadedProjects/<user id>/Payload
    OTHER_CODE_SIGN_FLAGS = --keychain <user id>
    PRODUCT_NAME = HttpServer
    PROVISIONING_PROFILE = xxxxx

note: Using new build system
note: Using codesigning identity override: iPhone Distribution:xxxx
note: Planning build
note: Constructing build description
warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'B4iProject' from project 'B4iProject')
CreateBuildDirectory /Users/administrator/Documents/UploadedProjects/<user id>/build (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    builtin-create-build-directory /Users/administrator/Documents/UploadedProjects/<user id>/build

MkDir /Users/administrator/Documents/UploadedProjects/<user id>/Payload/HttpServer.app (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    /bin/mkdir -p /Users/administrator/Documents/UploadedProjects/<user id>/Payload/HttpServer.app

ProcessProductPackaging /Users/administrator/Library/MobileDevice/Provisioning\ Profiles/d3f9e6ea-9623-4c4a-94a6-d2d721c9a402.mobileprovision /Users/administrator/Documents/UploadedProjects/<user id>/Payload/HttpServer.app/embedded.mobileprovision (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    builtin-productPackagingUtility /Users/administrator/Library/MobileDevice/Provisioning\ Profiles/d3f9e6ea-9623-4c4a-94a6-d2d721c9a402.mobileprovision -o /Users/administrator/Documents/UploadedProjects/<user id>/Payload/HttpServer.app/embedded.mobileprovision

WriteAuxiliaryFile /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/Entitlements.plist (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/Entitlements.plist

ProcessProductPackaging "" /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer.app.xcent (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
 

Entitlements:

{
    "application-identifier" = "xxxx.b4i.httpserver";
    "com.apple.developer.team-identifier" = xxxx;
    "get-task-allow" = 0;
}


    builtin-productPackagingUtility -entitlements -format xml -o /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer.app.xcent

WriteAuxiliaryFile /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-project-headers.hmap (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-project-headers.hmap

WriteAuxiliaryFile /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-own-target-headers.hmap (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-own-target-headers.hmap

WriteAuxiliaryFile /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-generated-files.hmap (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-generated-files.hmap

WriteAuxiliaryFile /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-all-target-headers.hmap (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-all-target-headers.hmap

WriteAuxiliaryFile /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer.hmap (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer.hmap

WriteAuxiliaryFile /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/all-product-headers.yaml (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/all-product-headers.yaml

WriteAuxiliaryFile /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-all-non-framework-target-headers.hmap (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-all-non-framework-target-headers.hmap

WriteAuxiliaryFile /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/HttpServer.LinkFileList (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/HttpServer.LinkFileList

CompileC /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/LS_page1.o /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/LS_page1.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    export LANG\=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -target arm64-apple-ios8.0 -fm-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/var/folders/lj/wrbzzxds6b53f88_rx3x7c800000gn/C/org.llvm.clang/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DB4I_VERSION\=13 -DNS_BLOCK_ASSERTIONS\=1 -DOBJC_OLD_DISPATCH_PROTOTYPES\=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.3.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility\=hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-b-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -iquote /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-generated-files.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-own-target-headers.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-all-target-headers.hmap -iquote /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-project-headers.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/Payload/include -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources-normal/arm64 -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/arm64 -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/administrator/Documents/UploadedProjects/<user id>/Payload -F../../Libs -MMD -MT dependencies -MF /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/LS_page1.d --serialize-diagnostics /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/LS_page1.dia -c /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/LS_page1.m -o /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/LS_page1.o

CompileC /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.o /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    export LANG\=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -target arm64-apple-ios8.0 -fm-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/var/folders/lj/wrbzzxds6b53f88_rx3x7c800000gn/C/org.llvm.clang/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DB4I_VERSION\=13 -DNS_BLOCK_ASSERTIONS\=1 -DOBJC_OLD_DISPATCH_PROTOTYPES\=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.3.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility\=hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-b-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -iquote /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-generated-files.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-own-target-headers.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-all-target-headers.hmap -iquote /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-project-headers.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/Payload/include -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources-normal/arm64 -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/arm64 -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/administrator/Documents/UploadedProjects/<user id>/Payload -F../../Libs -MMD -MT dependencies -MF /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.d --serialize-diagnostics /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.dia -c /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m -o /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.o
In file included from /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:2:
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.h:16:9: error: unknown type name 'b4i_httpserver'; did you mean 'b4i_server'?
@public b4i_httpserver* __svr;
        ^~~~~~~~~~~~~~
        b4i_server
In file included from /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:2:
In file included from /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.h:5:
/Users/administrator/Documents/Libs/iHttpServer.h:79:8: note: 'b4i_server' declared here
@class b4i_server;
       ^
In file included from /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:2:
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.h:31:22: error: unknown type name 'b4i_httpserver'; did you mean 'b4i_server'?
@property (nonatomic)b4i_httpserver* _svr;
                     ^~~~~~~~~~~~~~
                     b4i_server
In file included from /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:2:
In file included from /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.h:5:
/Users/administrator/Documents/Libs/iHttpServer.h:79:8: note: 'b4i_server' declared here
@class b4i_server;
       ^
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:127:16: error: unknown receiver 'b4i_httpserver'; did you mean 'b4i_server'?
self->__svr = [b4i_httpserver new];
               ^~~~~~~~~~~~~~
               b4i_server
In file included from /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:2:
In file included from /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.h:5:
/Users/administrator/Documents/Libs/iHttpServer.h:79:8: note: 'b4i_server' declared here
@class b4i_server;
       ^
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:164:8: error: no visible @interface for 'b4i_servletresponse' declares the selector '_sendfile::'
[_resp _sendfile:[[self->___c File] DirTemp] :_fn];
~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:172:8: error: no visible @interface for 'b4i_servletresponse' declares the selector '_sendnotfound:'
[_resp _sendnotfound:_fn];
~~~~~ ^~~~~~~~~~~~~
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:178:12: error: 'b4i_servletrequest' does not have a member named '__contenttype'
if ([_req->__contenttype isEqual:@"multipart/form-data"]) {
     ~~~~  ^
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:181:12: error: 'b4i_servletrequest' does not have a member named '__multipartfilename'
if ([_req->__multipartfilename Size]>0) {
     ~~~~  ^
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:185:40: error: 'b4i_servletrequest' does not have a member named '__multipartfilename'
const id<B4IIterable> group16 = [_req->__multipartfilename Keys];
                                 ~~~~  ^
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:217:8: error: no visible @interface for 'b4i_servletresponse' declares the selector '_sendstring:'
[_resp _sendstring:[@[_field,(@"<B>Recorded data</B><BR><a href=\"/index.html\">Back</a>")] componentsJoinedByString:@""]];
~~~~~ ^~~~~~~~~~~
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:240:7: error: 'b4i_servletrequest' does not have a member named '__id'
_req->__id = [self.bi NumberToString:@(self->__counterconenction)];
~~~~  ^
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:262:12: error: 'b4i_servletrequest' does not have a member named '__multipartfilename'
if ([_req->__multipartfilename Size]>0) {
     ~~~~  ^
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:266:39: error: 'b4i_servletrequest' does not have a member named '__multipartfilename'
const id<B4IIterable> group4 = [_req->__multipartfilename Keys];
                                ~~~~  ^
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:274:48: error: 'b4i_servletrequest' does not have a member named '__multipartfilename'
_tempfilename = [self.bi ObjectToString:[_req->__multipartfilename Get:(NSObject*)(_filename)]];
                                         ~~~~  ^
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:292:8: error: no visible @interface for 'b4i_servletresponse' declares the selector '_sendstring:'
[_resp _sendstring:([@[@"<!DOCTYPE html>\n",@"<html lang=\"en\" dir=\"ltr\">\n",@"\n",@"<head>\n",@"  <meta charset=\"utf-8\">\n",@"  <title>UPload</title>\n",@"</head>\n",@"\n",@"<body id=\"body\">\n",@"<B>Download: ",[self->___c SmartStringFormatter:@"" :(NSObject*)(_filename)],@"</B><BR>\n",@"<img src=\"",[self->___c SmartStringFormatter:@"" :(NSObject*)(_tempfilename)],@"\"><BR>\n",@"<a href=\"/fileupload.html\">Back To Upload</a><BR>\n",@"<a href=\"/index.html\">Back To Home</a>\n",@"</body>\n",@"</html>"] componentsJoinedByString:@""])];
~~~~~ ^~~~~~~~~~~
/Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m:299:8: error: no visible @interface for 'b4i_servletresponse' declares the selector '_sendstring:'
[_resp _sendstring:([@[@"<!DOCTYPE html>\n",@"<html lang=\"en\" dir=\"ltr\">\n",@"\n",@"<head>\n",@"  <meta charset=\"utf-8\">\n",@"  <title>UPload</title>\n",@"</head>\n",@"\n",@"<body id=\"body\">\n",@"<B>Download: ",[self->___c SmartStringFormatter:@"" :(NSObject*)(_filename)],@"</B><BR>\n",@"<a href=\"/fileupload.html\">Back to Upload</a><BR>\n",@"<a href=\"/index.html\">Back to Home</a>\n",@"</body>\n",@"</html>"] componentsJoinedByString:@""])];
~~~~~ ^~~~~~~~~~~
15 errors generated.

CompileC /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.o /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'B4iProject' from project 'B4iProject')
    cd /Users/administrator/Documents/UploadedProjects/<user id>
    export LANG\=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -target arm64-apple-ios8.0 -fm-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/var/folders/lj/wrbzzxds6b53f88_rx3x7c800000gn/C/org.llvm.clang/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DB4I_VERSION\=13 -DNS_BLOCK_ASSERTIONS\=1 -DOBJC_OLD_DISPATCH_PROTOTYPES\=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.3.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility\=hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-b-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -iquote /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-generated-files.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-own-target-headers.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-all-target-headers.hmap -iquote /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/HttpServer-project-headers.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/Payload/include -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources-normal/arm64 -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/arm64 -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/administrator/Documents/UploadedProjects/<user id>/Payload -F../../Libs -MMD -MT dependencies -MF /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.d --serialize-diagnostics /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.dia -c /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/main.m -o /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.o


Error: ** BUILD FAILED **


The following build commands failed:
    CompileC /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.o /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

how can i fix it ??
 

Star-Dust

Expert
Licensed User
Longtime User
Are you compiling in the example I published?

I see that the error should concern a class of is not b4i_server which is not part of my library. More I can not understand
 

Waldemar Lima

Well-Known Member
Licensed User
Are you compiling in the example I published?
yes

code below :
B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: HttpServer
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 8
    
#End Region

    #CertificateFile: ios_distribution.cer
    #ProvisionFile: mycert_provision.mobileprovision


Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Private xui As XUI
    
    Private Label1 As Label
    Private LabelUpload As Label
    Private ImageView1 As ImageView
    Private Svr As httpServer
    Private CounterConenction As Int = 0
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("Page1")
    NavControl.ShowPage(Page1)
    
    Svr.Initialize(Me,"Svr")
    Svr.Start(51051)
    Label1.Text=$"Server ip: ${Svr.GetMyWifiIp} ${51051}"$
    
    Dim unzip As Archiver
    unzip.Unzip(File.DirAssets,"www.zip",File.DirTemp,"")
End Sub

Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
    
End Sub

Private Sub Svr_NewConection(req As ServletRequest)
    CounterConenction=CounterConenction+1
    Log("New connection: " & req.RemoteAddress & " Counter: " & CounterConenction)
    req.ID=CounterConenction
End Sub

Private Sub Svr_Handle(req As ServletRequest, resp As ServletResponse)
    Dim fn As String = req.GetRequestURI.ToLowerCase
    Log("Request URI: " & fn)
    
    Select req.GetMethod
        Case "GET"
            If fn = "/" Then fn = "/index.html"
            If File.Exists(File.DirTemp,fn ) Then
                ' other file
                resp.SendFile(File.DirTemp,fn )
            Else if req.GetRequestURI="/hello" Then
                DinamicPage(req ,resp)
            Else
                'not found
                resp.SendNotFound(fn)
            End If
        Case "POST"
            If req.ContentType="multipart/form-data" Then
                ' Upload
                If req.MultipartFilename.Size>0 Then
                    For Each filename As String In req.MultipartFilename.Keys
                        Log("Start uploading: " & filename)
                    Next
                End If
            Else
                ' Post form
                Dim Field As String = ""
                For Each Param As String In req.ParameterMap.Keys
                    Field=$"${Field}${Param}=${req.ParameterMap.Get(Param)}<BR>"$
                Next
                resp.SendString(Field & $"<B>Recorded data</B><BR><a href="/index.html">Back</a>"$)
            End If
    End Select
End Sub

Private Sub Svr_UploadProgress (resp As ServletResponse, Progress As Float)
    LabelUpload.Text=$"Download $1.0{Progress*100}%"$
End Sub

Private Sub Svr_UploadedFile (req As ServletRequest, resp As ServletResponse)
    Dim tempfilename As String
    Dim OriginaleFileName As String
    If req.MultipartFilename.Size>0 Then
        For Each Filename As String In req.MultipartFilename.Keys
            tempfilename=req.MultipartFilename.Get(Filename)
            OriginaleFileName=Filename
        Next
    End If
    
    
    If OriginaleFileName.ToLowerCase.EndsWith("png") Or OriginaleFileName.ToLowerCase.EndsWith("jpg")Then
        'file image
        'File.copy(File.DirTemp,tempfilename,File.DirDocuments,OriginaleFileName)
        ImageView1.Bitmap=LoadBitmap(File.DirTemp,tempfilename)
        resp.Status=200
        resp.SendString($"<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
  <meta charset="utf-8">
  <title>UPload</title>
</head>

<body id="body">
<B>Download: ${Filename}</B><BR>
<img src="${tempfilename}"><BR>
<a href="/fileupload.html">Back To Upload</a><BR>
<a href="/index.html">Back To Home</a>
</body>
</html>"$)
    Else
        ' generic file
        resp.Status=200
        resp.SendString($"<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
  <meta charset="utf-8">
  <title>UPload</title>
</head>

<body id="body">
<B>Download: ${Filename}</B><BR>
<a href="/fileupload.html">Back to Upload</a><BR>
<a href="/index.html">Back to Home</a>
</body>
</html>"$)
    End If
    
    Log("Download: " & Filename)
End Sub

Private Sub DinamicPage(req As ServletRequest,resp As ServletResponse)
    resp.ContentType = "text/html"
    resp.SendString($"<img src='logo.png'/ width=100 height=100><br/>
<b>Hello world!!!</b><br/>
Your ip address is: ${req.RemoteAddress}<br/>
The time here is: ${DateTime.Date(DateTime.Now)} ${DateTime.Time(DateTime.Now)}<br/>
<a href='/'>Back</a>"$)
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
Are you compiling in the example I published?

I see that the error should concern a class of is not b4i_server which is not part of my library. More I can not understand
If you use the personal builder you have to copy the .h libraries
Which example are you trying, the one with webSocket or the one with just HTTP?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…