title: How to create XWalkWebResourceResponse?
body: <p>I am looking for a method to create <strong>XWalkWebResourceResponse</strong>. My case is following.</p>
  
  <p>I am creating custom <strong>XWalkResourceClient</strong> client that will intercept all network requests. All request that should be intercepted comes back as abstract wrapper - <strong>AppWebResourceResponse</strong>.</p>
  
  <pre><code>public final class CrossWebViewClient extends XWalkResourceClient {
      // other fields and constructor
  
      CrossWebResourceResponseMapper responseMapper;
  
      @Override
      public XWalkWebResourceResponse shouldInterceptLoadRequest(XWalkView view, XWalkWebResourceRequest request) {
          AppWebResourceRequest mappedRequest = requestMapper.toGenericRequest(request);
          AppWebResourceResponse interceptedResponse = requestInterceptor.shouldInterceptRequest(mappedRequest);
          if (interceptedResponse == null) {
              return super.shouldInterceptLoadRequest(view, request);
          }
          return responseMapper.toTargetResponse(interceptedResponse);
      }    
  }
  </code></pre>
  
  <p>The last step.
  I must adapt <strong>AppWebResourceResponse</strong> to <strong>XWalkWebResourceResponse</strong> and this is where I have an issue.</p>
  
  <pre><code>public class CrossWebResourceResponseMapper implements AppWebResourceResponse.Mapper&lt;XWalkWebResourceResponse&gt;  {
      @Override
      public XWalkWebResourceResponse toTargetResponse(final AppWebResourceResponse appResponse) {
          String mimeType = appResponse.getMimeType();
          String encoding = appResponse.getEncoding();
          int statusCode = appResponse.getStatusCode();
          String reasonPhrase = appResponse.getReasonPhrase();
          Map&lt;String, String&gt; headers = appResponse.getResponseHeaders();
          InputStream data = appResponse.getData();
  
  
          // ??? how to create response object?
          XWalkWebResourceResponse response;
  
          response.setMimeType(mimeType);
          response.setEncoding(encoding);
          response.setStatusCodeAndReasonPhrase(statusCode, reasonPhrase);
          response.setResponseHeaders(headers);
          response.setData(data);
          return response;
      }
  }
  </code></pre>
  
  <p>According to API has public constructor <code>new XWalkWebResourceResponse(bridge)</code> that consumes bridge object, though I have failed to find a way to retrieve particular bridge(org.xwalk.core.internal.XWalkWebResourceResponseBridge).</p>
  
  <p>Where can I retrieve <strong>XWalkWebResourceResponseBridge</strong>?</p>
  
  <p>Thanks, in advance.</p>
  
  <h1>Update on 25/04/2016:</h1>
  
  <p>According to <a href="https://stackoverflow.com/a/36831046/4726725">Xiaofeng</a> it is possible to create <strong>XWalkWebResourceResponse</strong>  object using <strong>XWalkResourceClient</strong> object.</p>
  
  <pre><code>public class XWalkWebResourceResponseMapper {
      public XWalkWebResourceResponse toTargetResponse(XWalkResourceClient client, AppWebResourceResponse appResponse) {
          String mimeType = appResponse.getMimeType();
          String encoding = appResponse.getEncoding();
          int statusCode = appResponse.getStatusCode();
          String reasonPhrase = appResponse.getReasonPhrase();
          Map&lt;String, String&gt; headers = appResponse.getResponseHeaders();
          InputStream data = appResponse.getData();
  
          return client.createXWalkWebResourceResponse(mimeType, encoding, data, statusCode, reasonPhrase, headers);
      }
  }
  
  public final class CrossWebViewClient extends XWalkResourceClient {
      @Override
      public XWalkWebResourceResponse shouldInterceptLoadRequest(XWalkView view, XWalkWebResourceRequest request) {
          AppWebResourceRequest mappedRequest = requestMapper.toGenericRequest(request);
          AppWebResourceResponse interceptedResponse = requestInterceptor.shouldInterceptRequest(mappedRequest);
          if (interceptedResponse == null) {
              return super.shouldInterceptLoadRequest(view, request);
          }
          return responseMapper.toTargetResponse(this, interceptedResponse);
      }
  }
  </code></pre>