Giter VIP home page Giter VIP logo

requests_stdlib's Introduction

Requests Standard Libary

A dependency free drop-in replacement for requests and requests-unixsocket for the common functions implemented using only Python 2 and 3 standard libraries.

Should I use this?

  • I have a project where I use requests because that's what everyone on stackoverflow tells me to do but I really only use simple GET/POST/PUT/DELETE functions.

  • I want to communicate with my Docker daemon but I think it's ridiculous that I have to install requests AND requests-unixsocket just to send HTTP requests to a unix socket file.

  • I have a project where the only dependency is requests and/or requests-unixsocket and I don't want to have to require users to install those just to use my project.

Well, if you find yourself thinking any of these when writing a project using request and/or requests-unixsocket then you should consider using this!

Prerequisites

None, that's the point.

Getting Started

Just drop requests.py into your project directory!

Usage

Features and usage are the same as requests quickstart for the following:

  • Make a Request link
  • Passing Parameters In URLs link
  • Response Content (except the encoding bit) link
  • JSON Response Content link
  • Custom Headers link
  • More complicated POST requests link
  • Response Status Codes (only the r.status_code bit) link
  • Response Headers link
  • Redirection and History (except the history bit) link

Unix socket usage is the same as requests-unixsocket documentation in regards to the scheme.

For example to send an HTTP request to /var/run/docker.sock you would use:

r = requests.get("http+unix://%2Fvar%2Frun%2Fdocker.sock/info")

TODO

I only implemented a subset of the features in requests which I found myself most commonly using. If there is interest for more of requests features I will implement them or feel free to make a PR if you want to add it yourself!

  • Binary Response Content link
  • Raw Response Content link
  • POST a Multipart-Encoded File link
  • Cookies link
  • Timeouts link

Acknowledgements

Referenced https://github.com/docker/docker-py/blob/master/docker/transport/unixconn.py for Docker's socket HTTPConnection code.

Contributing

Pull requests and contributions are welcomed!

Support

For any questions or concerns, please create an issue or contact me.

requests_stdlib's People

Contributors

clayshieh avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

theonlywayup

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.