Coder Social home page Coder Social logo

6xur / prethreaded-concurrent-proxy Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 662 KB

A concurrent caching proxy for handling HTTP/1.0 GET request

License: MIT License

Makefile 1.07% C 97.69% Perl 1.11% HTML 0.13%
caching-proxy http-proxy multithreading

prethreaded-concurrent-proxy's Introduction

Prethreaded Concurrent Proxy

This is a prethreaded concurrent web proxy with a 1MB web object cache that can handle HTTP/1.0 GET requests. The cache can handle objects up to 10KB and uses Pthread read/write locks for synchronisation. The proxy creates a fixed-sized thread pool at the start of its execution. The main thread listens for connections and pushes the connected file descriptors in a shared buffer. The worker threads then pop one descriptor at a time and handle the requests.

Request Headers

The proxy always send the following headers.

User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36;
Connection: close;
Proxy-Connection: close;

Specifying close as the value of the Connection and Proxy-Connection headers alert web servers that the proxy intends to close connections after the first request/response exchange is completed.

How to Run

The proxy can be started as follows.

./proxy port_number replacement_policy

The first argument spefies the port on which this proxy will listen for incoming connections. The second argument is the replacement policy, which can be either LRU (least recently used) or LFU (least frequently used).

For example, with the following command, the proxy should listen for connection on port 15214 and use LRU caching policy.

./proxy 15214 LRU

Testing with Browser

We can configure the browser to use our proxy for handling only plain HTTP requests.

Recommended: Firefox

  1. Open up settings and search for Proxy.

  2. In these settings, select manual proxy configuration.

  3. In the HTTP proxy field, enter in localhost(127.0.0.1) and the port your proxy is using.

  4. Browse to about:config, search for network.proxy.allow_hijacking_localhost and set this to true.

  5. Set browser.cache.disk.enable and browser.cache.memory.enable to false in about:config.

prethreaded-concurrent-proxy's People

Contributors

6xur avatar shbanu avatar

Watchers

 avatar

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.