Return after bad request

This commit is contained in:
Arlo Breault 2016-05-11 07:27:42 -07:00
parent 81931fa8e7
commit bdbabe5e0c

View file

@ -118,8 +118,10 @@ func proxyPolls(ctx *BrokerContext, w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
return return
} }
if string(body) != id { // Mismatched IDs! if string(body) != id {
log.Println("Mismatched IDs!")
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
return
} }
log.Println("Received snowflake: ", id) log.Println("Received snowflake: ", id)
// Wait for a client to avail an offer to the snowflake, or timeout if nil. // Wait for a client to avail an offer to the snowflake, or timeout if nil.
@ -162,7 +164,6 @@ func clientOffers(ctx *BrokerContext, w http.ResponseWriter, r *http.Request) {
case answer := <-snowflake.answerChannel: case answer := <-snowflake.answerChannel:
log.Println("Client: Retrieving answer") log.Println("Client: Retrieving answer")
w.Write(answer) w.Write(answer)
case <-time.After(time.Second * ClientTimeout): case <-time.After(time.Second * ClientTimeout):
log.Println("Client: Timed out.") log.Println("Client: Timed out.")
w.WriteHeader(http.StatusGatewayTimeout) w.WriteHeader(http.StatusGatewayTimeout)