Reputation: 8356
How does a server actually identify the requesting client address (IP), and send a response? Is it possible to get the IP address of requesting client in GAE?
Upvotes: 7
Views: 2404
Reputation: 80340
In a Java servlet you could use request.getRemoteAddr()
:
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
String ipAddress = req.getRemoteAddr();
}
Upvotes: 10
Reputation: 23824
If you are using Appengine with Go, the Request object contains the address in the string field RemoteAddr:
import (
"fmt"
"net/http"
)
func init() {
http.HandleFunc("/", handler)
}
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, r.RemoteAddr)
}
Upvotes: 2