@@ -86,8 +86,15 @@ func (svr *fakeserver)handle_api_object (w http.ResponseWriter, r *http.Request)
8686 }
8787 }
8888
89- parts := strings .Split (r .RequestURI , "/" )
90- if svr .debug { log .Printf ("fakeserver.go: Split request up into %d parts: %v\n " , len (parts ), parts ) }
89+ path := r .URL .EscapedPath ()
90+ parts := strings .Split (path , "/" )
91+ if svr .debug {
92+ log .Printf ("fakeserver.go: Request received: %s %s\n " , r .Method , path )
93+ log .Printf ("fakeserver.go: Split request up into %d parts: %v\n " , len (parts ), parts )
94+ if r .URL .RawQuery != "" {
95+ log .Printf ("fakeserver.go: Query string: %s\n " , r .URL .RawQuery )
96+ }
97+ }
9198 /* If it was a valid request, there will be three parts
9299 and the ID will exist */
93100 if len (parts ) == 4 {
@@ -100,11 +107,12 @@ func (svr *fakeserver)handle_api_object (w http.ResponseWriter, r *http.Request)
100107 http .Error (w , http .StatusText (http .StatusNotFound ), http .StatusNotFound )
101108 return
102109 }
103- } else if r . RequestURI != "/api/objects" {
110+ } else if path != "/api/objects" {
104111 /* How did something get to this handler with the wrong number of args??? */
112+ if svr .debug { log .Printf ("fakeserver.go: Bad request - got to /api/objects without the right number of args" ) }
105113 http .Error (w , http .StatusText (http .StatusBadRequest ), http .StatusBadRequest )
106114 return
107- } else if r . RequestURI == "/api/objects" && r .Method == "GET" {
115+ } else if path == "/api/objects" && r .Method == "GET" {
108116 result := make ([]map [string ]interface {}, 0 )
109117 for _ , hash := range svr .objects {
110118 result = append (result , hash )
@@ -142,6 +150,7 @@ func (svr *fakeserver)handle_api_object (w http.ResponseWriter, r *http.Request)
142150 } else if val , ok := obj ["ID" ]; ok {
143151 id = fmt .Sprintf ("%v" , val )
144152 } else {
153+ if svr .debug { log .Printf ("fakeserver.go: Bad request - POST to /api/objects without id field" ) }
145154 http .Error (w , "POST sent with no id field in the data. Cannot persist this!" , http .StatusBadRequest )
146155 return
147156 }
0 commit comments