All Questions

Tagged with
Filter by
Sorted by
Tagged with
107 votes
2 answers
218k views

Golang read request body multiple times [duplicate]

I am writing my own logginMiddleware. Basically, I need to log body of the request and the response. The problem that I faced is that when I read body, it becomes empty and I cannot read it twice. I ...
Rustam Ibragimov's user avatar
53 votes
4 answers
32k views

Why do I need to use http.StripPrefix to access my static files?

main.go package main import ( "net/http" ) func main() { http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) http.ListenAndServe(":8080", nil) } ...
Dante's user avatar
  • 11k
43 votes
3 answers
30k views

nginx map directive: why is it allowed only on http level?

There is a very useful directive in Nginx map. But it is possible to use it only on the http level (see docs here http://nginx.org/en/docs/http/ngx_http_map_module.html#map). For example, I have a ...
chestozo's user avatar
  • 1,273
34 votes
6 answers
49k views

multiple response.WriteHeader calls in really simple example?

I have the most basic net/http program that I'm using to learn the namespace in Go: package main import ( "fmt" "log" "net/http" ) func main() { http.HandleFunc("/", func(w http....
Corey Ogburn's user avatar
  • 24.3k
29 votes
1 answer
90k views

Nginx location configuration (subfolders)

lets say I've a path like: /var/www/myside/ that path contains two folders... let's say /static and /manage I'd like to configure nginx to have an access to: /static folder on / (eg. http://example....
Nubzor's user avatar
  • 522
27 votes
4 answers
15k views

Chrome ignores the ETag header and just uses the in memory cache/disk cache

If I understand correctly, the flow for using ETags works as described now: Browser sends the request to the server. Server sends back the image with an ETag Browser saves the ressource along with ...
Musterknabe's user avatar
  • 5,951
20 votes
3 answers
13k views

HTTP status code for "could not fulfill request for *known* reason"

HTTP 500 means the server could not fulfill the request for an unexpected reason. What is the best HTTP response code to use when the server could not fulfill the request for a reason that is known or ...
Alexander Mills's user avatar
20 votes
3 answers
8k views

How can I start the browser AFTER the server started listening?

In Go, how can I start the browser AFTER the server started listening? Preferably the simplest way possible. My code so far, super dumbed down to the point: package main import ( // Standard ...
Stefan Steiger's user avatar
19 votes
2 answers
12k views

Check errors when calling http.ResponseWriter.Write()

Say I have this http handler: func SomeHandler(w http.ResponseWriter, r *http.Request) { data := GetSomeData() _, err := w.Write(data) } Should I check the error returned by w.Write? ...
Dumitru's user avatar
  • 821
18 votes
2 answers
25k views

Simplest way to return literal JSON using gin gonic

I am learning Go by building a simple API interface for a web server. I want to return a simple message in JSON, when a default route is hit. So far, reading online, this is the easiest way to return ...
tritium_3's user avatar
  • 668
15 votes
5 answers
26k views

How start web server to open page in browser in golang?

How do I temporarily open a web page in browser using golang? Like here is how it is done using HTTPServer in python.
Ciasto piekarz's user avatar
14 votes
1 answer
12k views

How to serve http partial content with Go?

I have a webserver written in go and I'm serving some audio files from different sources (local, other servers, S3). I want to enable serving partial content for this files so the HTML audio tags are ...
Topo's user avatar
  • 4,903
14 votes
2 answers
3k views

Does nginx HttpLimitReqModule support per hour/day/week?

I seek a solution to do rate limit for HTTP API, for Nginx, there is already a module HttpLimitReqModule support this feature. But refer to the document, this module only supports per second and per ...
linbo's user avatar
  • 2,401
13 votes
2 answers
18k views

SimpleHTTPServer not found python3

I'm trying to write a simple server in python. So after watching tutorial, I'm trying to import a few modules. from http.server import HTTPServer from http.server import SimpleHTTPServer As the doc ...
Danial's user avatar
  • 582
12 votes
2 answers
23k views

Does Express disable CORS by default?

I have been asked to make sure that a new express server that I've set up enforces against Cross Origin Resource Sharing (CORS) unless the request is coming from a particular URL. I have found the ...
judgejab's user avatar
  • 529
12 votes
3 answers
19k views

Python -m http.server 443 -- with SSL?

Is it possible to create a temporary Python3 HTTP server with an SSL certificate? For example: $ python3 -m http.server 443 --certificate /path/to/cert
vskbdvds's user avatar
  • 203
12 votes
3 answers
13k views

How to properly close a Node.js TCP server?

I couldn't find a clear answer on Google or SO. I know a net.Server instance has a close method that doesn't allow any more clients in. But it doesn't disconnect clients already connected. How can I ...
Aviv Cohn's user avatar
  • 16.3k
12 votes
1 answer
25k views

HTTP/1.1 426 Upgrade Required

When trying to connect to localhost (with Terminal), I got this answer: HTTP/1.1 426 Upgrade Required Server: WebSocket++/0.3.0-alpha4 How can I respond to that to Upgrade?
Valentina Morigi's user avatar
11 votes
2 answers
17k views

http.ListenAndServe only works for localhost?

I've been successfully making use of http.ListenAndServe(":80", mux) to host my web service in Go. It only appears to work with localhost however. http.ListenAndServe("192.168.1.83:80", mux) This ...
Saurbaum's user avatar
  • 425
11 votes
2 answers
29k views

How to encode image to send over Python HTTP server?

I would like some help on my following handler: class MyHandler(http.server.BaseHTTPRequestHandler): def do_HEAD(client): client.send_response(200) client.send_header("Content-...
Thomas Wagenaar's user avatar
11 votes
1 answer
295 views

Why this simple web server is called even number times?

I'm trying to learn Go web programming, and here is a simple web server: it prints out the times being called. package main import ( "fmt" "net/http" ) var calls int // HelloWorld print the ...
Nick's user avatar
  • 8,741
10 votes
1 answer
5k views

Express: Is it necessary to respond with status 200?

Is it necessary to respond with a status 200 code or is it the default behavior? response.json({ status: 'OK', }); vs. response .status(200) .json({ status: 'OK', }); When I hit the ...
marcobiedermann's user avatar
10 votes
1 answer
4k views

Node.js HTTP2 server Error: socket hang up

Given the latest version of Node.js with experimental HTTP2 support: $ node -v v9.2.0 An HTTP2 server: var options = { key: getKey(), cert: getCert(), allowHTTP1: true } var server = http2....
Lance's user avatar
  • 77.1k
9 votes
3 answers
23k views

What is the standard acceptable request/response-timeout for API server (and Why)?

I'm working on developing both web-client and API server. I've been doing some research regarding default timeout, some are at 800ms, others 1200ms. However, I can't find the reason behind the ...
Saber Alex's user avatar
  • 1,614
9 votes
1 answer
3k views

How to non-destructively check if an HTTP client has shut down the connection?

I have a net/http Server serving a GET request (via ServeHTTP()) which can take a very long time to complete. Consequently, no client timeout is configured server side. However, the connected client ...
Alexander Klauer's user avatar
9 votes
2 answers
5k views

"Connection reset by peer" when benchmarking a simple Rust HTTP server with ab

I'm trying to write an extremely simple concurrent server in Rust to play with the language's concurrency primitives and its threading model. Here's my code: use std::io::prelude::*; use std::io::...
user avatar
9 votes
2 answers
715 views

Make netcat discard all bytes after disconnect

I use netcat to run a tiny development webserver through the bash, which is able to handle one connection at once. Netcat is started as follows (-k to make it survive multiple connections): nc -kl ...
ideaboxer's user avatar
  • 3,973
8 votes
1 answer
3k views

It takes too much time when using "template" package to generate a dynamic web page to client in Golang

It is so slow when using template package to generate a dynamic web page to client. Testing code as below, golang 1.4.1 http.Handle("/js/", (http.FileServer(http.Dir(webpath)))) http.Handle("/css/",...
catric mia's user avatar
  • 1,187
8 votes
2 answers
477 views

Requests to non-existing pages that all include "undefined”

Some odd requests appear on our logs since ~October 20, 2014. They've increased to about a few dozens a day so while not a big problem, it's still interesting to find out the reason. Earlier ones: ...
Collector's user avatar
  • 2,064
8 votes
4 answers
30k views

Reading from asyncio StreamReader

I am trying to extend the python asyncio HTTP server example that uses a streaming reader/writer (code). If I understand it correctly, the example handler read 100 bytes from the reader and echoes it ...
jdowner's user avatar
  • 727
8 votes
4 answers
21k views

HTTP Server Not Working (Python)

This is my first time trying to get HTTP servers working on my computer, so I have run into a few technical difficulties. I am using Python to develop the server, and I can access it on my localhost. ...
user avatar
8 votes
1 answer
578 views

Deploy Go webserver to Google compute engine

I just started to test Google compute engine. Now I'm trying to deploy my Go (golang) application on it, so that it can be reached from outside. I use compute engine in favor of the app engine, since ...
Kugel's user avatar
  • 828
8 votes
8 answers
37k views

ngrok error page: Failed to complete tunnel connection

Please help me in resolving this issue. Thanks
Anu Abraham's user avatar
7 votes
3 answers
2k views

Remove the .html extension from every file in a simple HTTP server

I want to make it so when someone visits a page on my Go HTTP server, they won't see the .html extension. E.g. when they visit https://example.org/test they will see the content of https://example.org/...
Marton's user avatar
  • 256
7 votes
2 answers
6k views

Python 3; Websockets Server & HTTP Server - run_forever & serve_forever

I am trying to run a websockets server and an http server in the same python application. It looks like I'm trying to run two forever loops and the 2nd loop is not getting activated. Any advice on how ...
user1898041's user avatar
7 votes
1 answer
7k views

How to call an API located on the same server?

I am trying to built a web framework (school project), the framework has to be API-oriented, and I will built the web app on an API-centric architecture, using PHP : The web backend will be a PHP ...
emandret's user avatar
  • 1,279
7 votes
0 answers
604 views

How to store SSE connections?

I'm setting up a Nodejs express server in Firebase. I have a Dashboard page. The user can save items to their dashboard at any time using a Chrome Extension. I want their new saved items to appear ...
stg123's user avatar
  • 71
6 votes
1 answer
13k views

ModuleNotFoundError: No module named 'http.server'; 'http' is not a package

I am trying to setup http server on my machine but I get the error: ModuleNotFoundError: No module named 'http.server'; 'http' is not a package I have 2 files in my project directory: http.py and ...
Luis0001's user avatar
6 votes
2 answers
8k views

Calling a Node.js server with Vue.js

I have a simple Node.js server up and running. This is the code: var http = require('http'); var server = http.createServer(); server.on('request', function(req, res) { res.writeHead(200, { ...
Arash Saidi's user avatar
  • 2,238
6 votes
2 answers
9k views

Can you send HTTP Response from another Server?

Silly question perhaps. I've been playing with Node.js lately, and like how easy it is to set up servers and make requests etc. I haven't tried yet, but was wondering how I might forward data from ...
Matt Catellier's user avatar
6 votes
1 answer
3k views

basic HTTP authentication on subsequent requests

The image below depicts basic HTTP authentication. The client requests /family resource and it is asked to identify itself. It does and now it can access the /family. The client then also asks for /...
sanjihan's user avatar
  • 5,880
6 votes
1 answer
824 views

Server Architecture - Redis vs Socket server

I have a game server which is going to run on a few instances. World 1, World 2, World 3 Each world is a server that runs on a different IP Address. There is a list of what the game should have: ...
Ben Beri's user avatar
  • 1,141
6 votes
3 answers
3k views

npm http-server downloads index.html instead of serving

I am using http-server with ssl certificate in order to test facebook instant games. However, while server is running localhost makes my browser download index.html file instead of actually serving it ...
Stanley's user avatar
  • 151
6 votes
3 answers
188 views

How to check if clients are starved in an apache server?

How would you monitor a server performance in sense of : Count requests that has been timedout without processing at all (client was starved) Count requests that has been timedout while in process ...
Ofek Ron's user avatar
  • 8,500
6 votes
1 answer
1k views

Port doesn't close when I run ListenAndServe() in a test function, how do I fix this?

When I call http.ListenAndServe() in a test function the port does NOT close even after the tests have finished and the process has terminated. So the next time I run the tests I get the error "...
Chris W's user avatar
  • 805
6 votes
2 answers
6k views

How to handle multiple ssl server with nginx

I have 2 SSL webservers that I have to handle with nginx. I also have a http server (the redirection works fine). The redirections works well when i handle just http and https (only one ssl webserver)...
Abdel31's user avatar
  • 61
5 votes
2 answers
5k views

Keep running Go Server as background process

I want to keep my Golang language web server working regardless of an error happens or not. How to keep running it always?
Murtadha S.'s user avatar
5 votes
1 answer
3k views

Golang communicating the name of the file served to the browser/client

I'm serving some files dynamically using golang and the following code handles the actual serving of files: data, err := ioutil.ReadFile(file.Path) logo.RuntimeError(err) http....
George's user avatar
  • 3,791
5 votes
1 answer
17k views

How to capture and read headers of incoming HTTP requests in Flask? [duplicate]

I want to read the headers of an incoming request to my server to track its location and other attributes. For example: If someone clicks on an URL, how will I be able to read the headers of the ...
dvabhishek's user avatar
5 votes
4 answers
12k views

Node JS not listening to port 1337 on server

I'm trying to open a port on particular lamp server hosted by Google and I'm in connection with the server via ssh. I've followed this link to configure nvm and the latest Node JS(v0.12.5) on it. ...
Pranav Nemade's user avatar

1
2 3 4 5
21