Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable/disable browser cache headers #30

Closed
GoogleCodeExporter opened this issue May 6, 2016 · 1 comment
Closed

enable/disable browser cache headers #30

GoogleCodeExporter opened this issue May 6, 2016 · 1 comment

Comments

@GoogleCodeExporter
Copy link

package org.sandrop.webscarab.plugin.proxy;

import java.io.IOException;
import org.sandrop.webscarab.httpclient.HTTPClient;
import org.sandrop.webscarab.model.Preferences;
import org.sandrop.webscarab.model.Request;
import org.sandrop.webscarab.model.Response;

public class BrowserCache extends ProxyPlugin {

    private boolean _enabled = false;

    public BrowserCache() {
        parseProperties();
    }

    public void parseProperties() {
        String prop = "BrowserCache.enabled";
        _enabled = Preferences.getPreferenceBoolean(prop, false);
    }

    public String getPluginName() {
        return new String("Browser Cache");
    }

    public void setEnabled(boolean bool) {
        _enabled = bool;
        String prop = "BrowserCache.enabled";
        Preferences.setPreference(prop,Boolean.toString(bool));
    }

    public boolean getEnabled() {
        return _enabled;
    }

    public HTTPClient getProxyPlugin(HTTPClient in) {
        return new Plugin(in);
    }    

    private class Plugin implements HTTPClient {

        private HTTPClient _in;

        public Plugin(HTTPClient in) {
            _in = in;
        }

        public Response fetchResponse(Request request) throws IOException {
            if (_enabled) {
                // we could be smarter about this, and keep a record of the pages that we 
                // have seen so far, and only remove headers for those that we have not?
                request.deleteHeader("ETag");
                request.deleteHeader("If-Modified-Since");
                request.deleteHeader("If-None-Match");
            }
            return _in.fetchResponse(request);
        }

    }

}

Original issue reported on code.google.com by supp.san...@gmail.com on 4 Jul 2012 at 6:22

@GoogleCodeExporter
Copy link
Author

Original comment by supp.san...@gmail.com on 9 Jul 2012 at 7:45

  • Changed state: Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant