You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/11/25 03:31:32 UTC

[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5071: Delivery Service Request Overhaul

rawlinp commented on a change in pull request #5071:
URL: https://github.com/apache/trafficcontrol/pull/5071#discussion_r530085284



##########
File path: traffic_ops/v3-client/session.go
##########
@@ -353,6 +353,48 @@ func (to *Session) request(method, path string, body []byte, header http.Header)
 	return to.ErrUnlessOKOrNotModified(r, remoteAddr, err, path)
 }
 
+// requestWithoutClosingBody makes a request to Traffic Ops, trying to refresh
+// the cookie if it is expired - but only once. It determines a cookie is
+// expired not by examining the cookie itself, but by recognizing a
+// 401 Unauthorized response status code from the server. It returns, in order,
+// a pointer to an HTTP response - which, if there is no error, contains a
+// non-nil Body the caller is expected to close -, the remote address of the
+// Traffic Ops server used to service the request, and any error that occurred.
+// Note that any response code greater than or equal to 400 will result in an
+// error - and that means that it cannot be assumed that the response object is
+// nil if there is an error! This is to provide greater visibility to
+// HTTP-level errors while still giving back as much information as possible.
+func (to *Session) requestWithoutClosingBody(method, path string, body []byte, header http.Header) (*http.Response, net.Addr, error) {

Review comment:
       I don't really want us to add yet another underlying method to the client that is only used by a small fraction of top-level methods. It makes the client inconsistent and confusing. Instead, is there a way to incorporate these changes into the single shared method I've created [here](https://github.com/apache/trafficcontrol/pull/5334/files#diff-cbf10b941a6c6105c02e8e50de8be60c46c104c53f2f531f1105dffbacd49737R339)? I'm open for suggestions if you'd like to review that approach. I'd just like the top-level method bodies to be concise and use the same underlying method for consistency.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org