I have got a problem using Selenium in Java for testing. Here is the story: sometimes our Tomcat rejects requests coming to our Spring backend, because the size of header is too large. Our solution is simple: we have increased the maximum size of header from default 8kB to 16kB.
Now comes the tricky part, where I want to write an automatic test for that case. I think that not a stupid solution would be to define a method, which creates the header with some data and the size larger than 8kB and lower than 16kB, send it to our service and check if it passes (and of course a negative case such as filling the header with too much data extending the maximum). Now I'm really struggling with making that work. To be precise, I am not sure how to get the size of headers in bytes using Selenium in Java. I have been wasting all today afternoon looking for some built-in methods or libraries in Java which can do it, but frankly with no result.
I managed to figure out one way to do it, but I assume that the accuracy of it can be low. Can I just fill the header value as a String and get the array of bytes, then the length of it? The main disadvantage of this would be probably that I can take the largest part of that header which I wrote by myself, but I still wouldn't be sure how many percent of the actual size it covers.
In that case, does Java or Selenium, or God knows whatever have something, what can check/get the actual size of header prepared for request from code line?