PUT and DELETE Methods with HttpStream?

Posted on

Question :

Does anyone know if I can use HttpStream with methods PUT and / or DELETE ?

HttpStream.Options options = new HttpStream.Options();
options.httpType = HttpStream.GET;

HttpStream httpStream = new HttpStream(new URI(VarGlobais.url), options);

no HttpStream.Option is only accepted GET and POST . How do I get around this?

I know that HttpConn has these options of PUT and DELETE , however when using HttpConn in WinCE it gives error saying that Class HttpConn is not found, so today I’m using the HttpStream .


Answer :

From the Javadoc (my emphasis):


The default type is GET.
  You can also define a custom type, like if you want to use restful services. In this case, the header will be set to what you store in the httpType String. Note that, to use another http method, append to space .

Example with method PUT :

HttpStream.Options options = new HttpStream.Options();
options.httpType = "PUT ";

Example with CUSTOMMETHOD any:

HttpStream.Options options = new HttpStream.Options();
options.httpType = "CUSTOMMETHOD ";

Note the spaces between the end of the method name and the end of the string.

If you have a method that is not described in HttpStream and you want to indicate that it sends data, you need to indicate this in Options :

HttpStream.Options options = new HttpStream.Options();
options.httpType = "PUT ";

About HttpConn

The class HttpConn is a wrapper over HttpStream . It does not provide any more functionality than using HttpStream pure. It makes life a lot easier, but you can get the same results using HttpStream .

Class HttpConn not found?

This class belongs to a library. To import the libraries into the project, you need to export them as .tcz and put the name of the generated file in all.pkg .


Automatic dependency management

From TotalCross 4, we have supported the automatic generation of the% s of intermediate% s and their management in .tcz . This was even mentioned as one of the release highlights .

Free translation:


  • Do you want to add your dependencies automatically? Take a look at all.pkg

    • The file tc-compiler-help is dynamically updated with its dependencies, returning to its initial state at the end of the execution


  • See examples of build :

    • Build for multiple platforms here

    • Must compile with dependencies all.pkg , magical-utils and tc-utilities here


To enable the use of tc-components , the first step is to add dependency to the project:



To properly download this dependency, you must use the TotalCross OR Maven repository to download the tc-compiler-help project on your machine

To actually use the build wizard, you should start by creating an object of type tc-compiler-help .

CompilationBuilder meets (almost) the same demands that CompilationBuilder meets. In fact, tc.Deploy will make calls to CompilationBuilder securely / in sandbox . You can set your key, set the main class, extraneous build parameters, define platforms, modify environment variables before running tc.Deploy freely.


The only cases where tc.Deploy has features that tc.Deploy does not meet is to create CompilationBuilder or executable from tcz or .class ; but this was not a defect, it was design choice, so we only allowed to create .zip s and executables from tcz .

Nearly all configuration methods for .jar return the object itself. This allows you to thread method calls.

In addition to the traditional build settings in TotalCross, you can define which dependencies it finds that need to be compiled to generate the executable. To do this, just call CompilationBuilder ” with a function that will judge, based on the dependency path, whether it should enter the executable or not.

Internally, setMustCompile passes all elements of the classpath to be judged by the function.

To run this CompilationBuilder in your project:

  • create a class with a method CompilationBuilder CompilationBuilder public static void main; nesse método, você deve configurar o com.hello.world.ClasseCompilacao ‘;
  • run direta ou indiretamente; vamos chamar essa classe de
  • Leave a Reply

    Your email address will not be published. Required fields are marked *