Coder Social home page Coder Social logo

http-md5's Introduction

http-md5

This project makes HTTP requests and prints the address of the request along with the MD5 hash of the response. In order to perform multiple requests concurrently, it implements a pool of workers that perform the task for each URL independently and in parallel. The maximum number of concurrent requests is defined by a flag -parallel and its default value is 10. As soon as each worker perform the HTTP request, reads the response body and compute its checksum, it prints the URL followed by its MD5. Therefore, the order in which the URLs are provided as arguments might not be followed when outputting the result.

How to run

This project was tested on a machine with go version go1.16.2 darwin/amd64. To run the project, follow the instructions below:

  1. Build the project with the following command:
go build .
  1. Execute the binary passing URLs as arguments:
./http-md5 google.com http://bbc.com facebook.com yahoo.com

You can alternatively inform the limit of concurrent workers with the flag parallel as such:

./http-md5 -parallel 3 google.com http://bbc.com facebook.com yahoo.com

Considerations

  • URL validation: the solution does not perform any robust URL validation, besides including the prefix "http://" in case the URL does not have it already. One could use a regular expression to validate them, but since the description of the task did not mention what URL formats are valid I decided to not include. The solution can make HTTP requests on invalid URLs which will eventually fail, just like requesting any valid URL that does not exist, for example, "http://silverpotatoes.com".

  • Error handling: since the description of the task did not mention how to handle errors, this solution also prints the errors, but with a [ERROR] prefix. This way the user can know which URLs failed to have their checksum computed. Requests in which their responses have a status code different from HTTP 200 OK are considered as an error case.

http-md5's People

Contributors

fdefabricio avatar

Watchers

James Cloos avatar  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.