In my project, I have implemented networking calls using java.net.HttpUrlConnection.
Now, I want to test the responses I get from the real server for these http requests. I'm using robolectric framework in combination with powermock.
When running the test, some of the responses say particular headers are missing (E.g., 'Invalid or missing the origin header'), although I have put all necessary headers as request properties. The responses are all okay while running on real device, and also while testing on Postman with the same headers.
Now, as far as my understanding, robolectric has an intermediate HTTP layer which intercepts the request calls. I have tried
FakeHttp.getFakeHttpLayer().interceptHttpRequests(false);
But this still results in same error.
What is the reason of such unexpected erroneous response and what is the walk-around through this, i.e. how to test the response from real server using robolectric framework?
Thank you.