Hot answers tagged

59 votes
Accepted

Single instance of reusable HttpClient

You don't need multiple instances. In fact, HttpClient is designed specifically to persist and be used for multiple requests (see: ...
19 votes
Accepted

Multi-threaded web server serving HTML, images, etc

Calling strcat in a loop is inefficient The function strcat works the following way: It must first search the entire destination ...
17 votes
Accepted

Python script that pulls in and display a random xkcd comic

Xkcd as a class isn't particularly well-named: you're actually representing a "site", "session" or "downloader", distinct from an ...
  • 53.2k
16 votes
Accepted

Refactoring a Crawler

Assignment Branch Condition size for fetch_images is too high. [22.41/15] What that warning is saying is that, according to rubocop's standard, you have too many ...
  • 2,722
15 votes
Accepted

Golang HTTP status checker

Style Use CamelCase only. last_status -> lastStatus, site_json -> ...
  • 506
14 votes
Accepted

HTTP request and HTTP client abstractions

Code Review A standard naming convention (if there can be said to be one). Is that user defined types start with an initial capitol letter. Other identifiers that name objects (or functions) start ...
  • 91.9k
13 votes
Accepted

Creating HTTP proxies for services

Create a strategy to find the mapped implementation of the interface provided: ...
  • 3,216
12 votes

Resumable HTTP download class

I would not directly write to the console. You are best off building an ILogger interface, then create a ConsoleLogger class ...
10 votes
Accepted

Increase download speed of code

JavaDoc, JavaDoc, JavaDoc. // States: // 1 = downloading // 2 = completed // 0 = paused // -1 = failed AtomicInteger currentState = new AtomicInteger(1); This is ...
  • 7,632
10 votes
Accepted

Parsing an XML File for a single word/phrase

Linq to XML is your friend var serverName = XDocument.Load(response.GetResponseStream()).Element("Server").Value; Your code will be easily broken if someone adds ...
10 votes

Resumable HTTP download class

Your FileStream looks like it is an IDisposable as well, you should put it into a using statement as well, then you don't have to worry about missing a chance to dispose it. Right here ...
  • 28.5k
10 votes

Simple webserver in C

Are you sure that &(int) { 1 } does what you want it to do? I'm not sure it does. Using malloc()/strcpy() is probably ...
  • 2,026
10 votes
Accepted

Repeatable HTTP requests in Python

If you are making many requests, it is worth it to have a look at requests.Session. This re-uses the connection to the server for subsequent requests (and also the ...
  • 40.6k
9 votes

Download Images as fast as possible

Just a few quick remarks (for now): vbNullString is a remnant of VB6 (which I think would be under the ...
9 votes
Accepted

Basic Python HTTP Server

ServerSocket self.handler The handler evaluation in __init__ can be accomplished with an or ternary operation. It's clearer to ...
  • 1,928
9 votes
Accepted

Simple HTTP Server

Note: This review focuses on the use of C++, rather than the functionality. Naming: IMHO, the use of "do" at the start of function names is unnecessary and makes the code harder to read. The names ...
9 votes

Python script that pulls in and display a random xkcd comic

The use of a class here is basically strictly a bad idea. This is such a simple script that if I were actually writing it, I would probably just put all the code under ...
  • 394
8 votes
Accepted

WSGI static file handler

In total, a process in Unix systems can have a limited number of open filehandles. By default this is only say 1024 per process in Linux; all of the open sockets also consume file descriptors. Even if ...
8 votes
Accepted

Receiving a JSON string response from a URL

I would consider creating an AsyncClient and a SyncClient interface/classes instead of one. I guess users of the current Client ...
  • 29.8k
8 votes
Accepted

Non-blocking, non-threaded HTTP client implementation

Have you considered using HttpClient class from .Net 4.5+? That makes your code lot cleaner. Also why not take Async pattern all the way? From your initiator (button click or main etc) you can call ...
  • 298
8 votes
Accepted

Searching the Foursquare API with Python

Named tuples Business is nothing short of a tuple where each attribute is named. Rather than going through the verbosity of writing everything out, you can just ...
  • 18.3k
8 votes
Accepted

Reading and returning the HTML content from a specified URL

There are a couple of minor technical issues: The content variable is unnecessary, because you can simply return ...
  • 110k
7 votes
Accepted

Making this site navigation less verbose

First, a few points on case statements. The last three cases all do the same thing. To reduce duplication, you can allow cases to fall through: ...
  • 2,722
7 votes

Parallel "wget" in Java

Just a rant, someone else will do the real work, but for me it's hard to read. durl = url; When I see it..... what to say? So slowly... "url" is fine, everybody ...
  • 13.4k
7 votes

Golang concurrent HTTP request

Inside SendRequst you are calling SendRequest again, which will make your stack full of recursive calls.
7 votes

Minimal webserver in C++

The server announces HTTP 1.1, therefore it must support HTTP 1.1 features, most importantly pipelining (client has a right to send multiple requests over the same socket). In any case, if you chose ...
  • 54.1k
7 votes
Accepted

Unit testing HTTP requests

I really rather think you have the right idea with the interface and your real class. I do heartily endorse your use of readonly which doesn't get a lot of exposure....
7 votes
Accepted

Asynchronous HTTP JSON request

I know this is technically outside the scope of the review here, but your first parameter's type is Method. This enum desperately needs to be renamed. When I see <...
  • 25.2k
7 votes
Accepted

Scraping GitHub for security vulnerabilities

PEP8 - click, read, apply PEP8 gives coding conventions for the Python code comprising the standard library in the main Python distribution you should use 4 spaces per indentation level function ...
7 votes
Accepted

Simple Rust Webserver

Learn to love rustfmt: Spaces go between comma-separated items: -use std::io::{Read, Write,BufReader, BufRead}; +use std::io::{Read, Write, BufReader, BufRead}; ...
  • 8,388

Only top scored, non community-wiki answers of a minimum length are eligible