Page 1 of 1

Http with forceHttp1 true

PostPosted: Mon May 01, 2023 10:49 am
by JuanMartin
Hi

In Servoy 2023.03.0, I try to send any image to Prestashop 1.7.6.7 with the Http protocol forceHttp1 true, but dosen't work

I use this code:
Code: Select all
  var config=plugins.http.createNewHttpClientConfig();
    config.forceHttp1=true;
    cliHttp = plugins.http.createNewHttpClient(config);
       var postRequest = cliHttp.createPostRequest(url);
   postRequest.addHeader('enctype', 'multipart/form-data');
   postRequest.addHeader('method', 'POST');
   postRequest.addParameter('Content-Disposition', 'form-data;name="image"');
   postRequest.addParameter('Content-Type', content);
   postRequest.addFile('image', tempFile);
   response = postRequest.executeRequest();
   
   result = utils.stringReplace(response.getResponseBody(), "><", ">\n<");


It took a long time to respond and when it does it gives this error:
ERROR com.servoy.j2db.util.Debug - response.getResponseBody API was called while response is null due to request exception: java.net.SocketTimeoutException: 50000 MILLISECONDS

Thanks

Re: Http with forceHttp1 true

PostPosted: Mon May 08, 2023 8:38 pm
by JuanMartin
It is already working, in case someone needs it, it is as follows:

Code: Select all
var url = 'https://prestashop_url /api/images/products/' + product_prestahop_id;
    var config=plugins.http.createNewHttpClientConfig();
    config.forceHttp1=true;
    cliHttp = plugins.http.createNewHttpClient(config);
    var postRequest = cliHttp.createPostRequest(url);
   postRequest.addHeader('enctype', 'multipart/form-data');
   postRequest.addHeader('method', 'POST');
   postRequest.addParameter('Content-Disposition', 'form-data;name="image"');
   postRequest.addParameter('Content-Type', content);
   postRequest.addFile('image', tempFile);
   postRequest.forceMultipart(true);
   postRequest.usePreemptiveAuthentication(true);
   response = postRequest.executeRequest(_sa.presta_clientes ,"a");
   result = utils.stringReplace(response.getResponseBody(), "><", ">\n<");

Re: Http with forceHttp1 true

PostPosted: Fri Jun 16, 2023 1:59 pm
by JuanMartin
Hi
I update to Servoy 2023.3.2 and forceHttp1=true dosenĀ“t works again
With the Servoy 2023.3.1 it worked perfectly

I do not see that there has been any modification of this part in the documentation, but the truth is that with Servoy 2023.3.2 it does not work

Thanks