Interface EventSource.RequestTransformer

  • Enclosing class:
    EventSource

    public static interface EventSource.RequestTransformer
    Interface for an object that can modify the network request that the EventSource will make. Use this in conjunction with EventSource.Builder.requestTransformer(EventSource.RequestTransformer) if you need to set request properties other than the ones that are already supported by the builder (or if, for whatever reason, you need to determine the request properties dynamically rather than setting them to fixed values initially). For example:
    
     public class RequestTagger implements EventSource.RequestTransformer {
       public Request transformRequest(Request input) {
         return input.newBuilder().tag("hello").build();
       }
     }
     
     EventSource es = new EventSource.Builder(handler, uri).requestTransformer(new RequestTagger()).build();
     
    Since:
    1.9.0
    • Method Detail

      • transformRequest

        okhttp3.Request transformRequest​(okhttp3.Request input)
        Returns a request that is either the same as the input request or based on it. When this method is called, EventSource has already set all of its standard properties on the request.
        Parameters:
        input - the original request
        Returns:
        the request that will be used