title: How to create a okhttp3 Request from an HttpServletRequest?
body: <p>When my Java web application receives an HTTP POST request, it needs to create a new OkHttp3 Request from the HttpServletRequest and send this to another URL. The original post request could be simple form data or multi-part.</p>
  
  <p>Here's the interface that I am looking to implement:</p>
  
  <pre><code>import okhttp3.Request;
  
  public interface OkHttp3RequestBuilder {
      Request create(HttpServletRequest request);
  }
  </code></pre>
  
  <p>Looks like the challenge boils down to how I would create an okhttp3.RequestBody. Here's the relevant part of the implementation...</p>
  
  <pre><code>    final HttpUrl targetUrl = HttpUrl.get("http://internal.xyz.com");
  
      final RequestBody requestBody = // ?????
      final Request httpRequest = new Request.Builder()
              .post(requestBody)
              .url(targetUrl)
              .build();
      return httpRequest;
  </code></pre>
  
  <p>How do I go about doing it? Any suggestions? Thanks!</p>