Giter Site home page Giter Site logo

pycharles's People

Contributors

richtermb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pycharles's Issues

suggestions for API additions

Thanks for making this! I needed a quick tool to manipulate HTTP POST requests I had logged in Charles, and this was quite helpful.

When I used it, I needed to make a few changes. The first two are probably no-brainers to add, and I only wanted them to keep knowledge about the JSON structure from leaking out into my tool.

On the CharlesRequest class, I added

    def get_headers(self):
        return self.request_dict['request']['header']['headers']

    def get_body(self):
        return self.request_dict['request']['body']['text']

The other thing I needed was to build a session from a file-like object. I'm not sure I've thought that through carefully enough that you'll want to add it just the way I did, but here's how I changed the CharlesSession constructor:

    def __init__(self, request_list=list(), path=None, file=None):
        if file is not None:
            self._all_requests = [CharlesRequest(r) for r in json.load(file)]
        elif len(request_list) == 0 and path is not None:
            with open(path, 'r') as f:
                self._all_requests = [CharlesRequest(r) for r in json.load(f)]
        elif len(request_list) > 0 and path is None:
            self._all_requests = [CharlesRequest(r) for r in request_list]
        else:
            self.fail('only one initialization parameter should be specified')
        _assign_indexes(self._all_requests)

All my mods and my little tool are all available in my public repo under the same license as pycharles in case you find it interesting or useful.

I haven't used this enough and thought it through carefully enough to make it a pull request (and probably won't end up doing so) but it seemed worth sharing anyway.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.