0

This is the function containing the request :

Future<String> getRequest(String serviceName, Map<String, String> a) async {
  var responseBody = '{"data": "", "status": "NOK"}';
  try {
    http.Response response =
        await http.get(_urlBase + '$_serverApi$serviceName', headings: a);

    if (response.statusCode == 200) {
      responseBody = response.body;
    }
  } catch (e) {
    // An error was received
    throw new Exception("GET ERROR");
  }
  return responseBody;
}

and this is where i call it :

void _confirm() async {
    if (_formKey.currentState.saveAndValidate()) {
      print(_formKey.currentState.value);
      Map<String, String> c =
          Map<String, String>.from(_formKey.currentState.value);
      // just below
      var a = await auth.getRequest('se_connecter', c);

      print(a);
    } else {
      print(_formKey.currentState.value);
      print("validation failed");
    }
}

everytime i try it, the code in the try bloc fails, and it throws the exception (ClientException after i removed try and catch bloc)

This the exception stacktrace :

I/flutter (10979): #0      IOClient.send 
package:http/src/io_client.dart:65
I/flutter (10979): <asynchronous suspension>
I/flutter (10979): #1      BaseClient._sendUnstreamed 
package:http/src/base_client.dart:176
I/flutter (10979): #2      BaseClient.get 
package:http/src/base_client.dart:35
I/flutter (10979): #3      get.<anonymous closure> 
package:http/http.dart:46
I/flutter (10979): #4      _withClient 
package:http/http.dart:166
I/flutter (10979): #5      get 
package:http/http.dart:46
I/flutter (10979): #6      getRequest 
package:event_app/auth.dart:125
I/flutter (10979): #7      ConnectPageState._confirm 
package:event_app/pages/connect_page.dart:28
I/flutter (10979): #8      _InkResponseState._handleTap 
package:flutter/…/material/ink_well.dart:706
I/flutter (10979): #9      _InkResponseState.build.<anonymous closure> 
package:flutter/…/material/ink_well.dart:789
I/flutter (10979): #10     GestureRecognizer.invokeCallback 
package:flutter/…/gestures/recognizer.dart:182
I/flutter (10979): #11     TapGestureRecognizer.handleTapUp 
package:flutter/…/gestures/tap.dart:486
I/flutter (10979): #12     BaseTapGestureRecognizer._checkUp 
package:flutter/…/gestures/tap.dart:264
I/flutter (10979): #13     BaseTapGestureRecognizer.
2
  • Can you add stacktrace of the exception to question? Commented Apr 25, 2020 at 16:02
  • The problem is related to allowLegacyUnsafeRenegotiation It has been answered here Commented Jan 29, 2023 at 10:04

2 Answers 2

2

In my case (sometimes instead of blank appeared the error "HttpException: Connection closed before full header was received") the call was to an https address using Microsoft Internet Information Services as backend, in the SSL settings of the website in IIS i had mistakenly set "Client certificates: Accept" instead of "Client certificates: Ignore", setting "Ignore" solved the problem.

Sign up to request clarification or add additional context in comments.

Comments

1

Solved, the problem was the ssl encryption, so i removed it from my backend.

2 Comments

what did you remove?
in the flask app, in app.run() function i added ssl_context='adhoc' , so that it runs on HTTPS with an SSL encryption instead of just HTTP

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.