jcmturner / gokrb5

Pure Go Kerberos library for clients and services
Apache License 2.0
723 stars 245 forks source link

Different lengths of req.Body and req.ContentLength #457

Open kerwin-wang opened 2 years ago

kerwin-wang commented 2 years ago

Hello! I have 2 question that I need your help.

  1. When I use krb5, I found that the following code will cause different lengths of reqbody and reqlength during use. So I can only change it to the second piece of code, what I want to ask is if I am doing it correctly. Does it go against your original design.
  2. If I can only develop with my own modified code, can I fork your code to my own private repository or a github repository? can i do this? Please give me authorization.

1- original code

spnego/http.go (line: 83)

var body bytes.Buffer
if req.Body != nil {
  // Use a tee reader to capture any body sent in case we have to replay it again
  teeR := io.TeeReader(req.Body, &body)
  teeRC := teeReadCloser{teeR, req.Body}
  req.Body = teeRC
}

2- changed code

var body []byte
  if req.Body != nil {
  body, _ = ioutil.ReadAll(req.Body)
  req.Body = ioutil.NopCloser(bytes.NewBuffer(body))
}
jcmturner commented 2 years ago

I'll need to revisit why TeeReader was used here. It may be that this is overly complexy and your suggestion is a simpler way to achieve what's needed but it will need to be looked into.

2) gokrb5 is licensed under the Apache v2 license so you can take a copy and modify but you need to include the license and notice files if you distribute your copy. Please refer to the license for more details on the terms of the Apache v2 license. The license is the authority for how gokrb5 can be used.