[go-nuts] Re: Draining http response bodies

2021-10-07 Thread Amnon
Added issue https://github.com/golang/go/issues/48860 On Thursday, 7 October 2021 at 08:36:25 UTC+1 Amnon wrote: > Is it necessary for a http client to fully read the http response body? > > Opinion on the Go forums seems divided > https://forum.golangbridge.org/t/do-i-need-to-read-the-body-befo

[go-nuts] [ANN] Pure Go NFSv4 client

2021-10-07 Thread Alex Besogonov
Hi! Here's my pure Go NFSv4 client. It's designed to work with Amazon EFS (Elastic FileSystem) but also can work against Linux kNFSD or Ganesha (in fact, Ganesha is used for integration testing). Enjoy: https://github.com/Cyberax/go-nfs-client -- You received this message because you are subs

Re: [go-nuts] Re: Questions about documentation of Go standard library

2021-10-07 Thread Kamil Ziemian
> The io.ReadAll function and the io.Reader interface Read method are not the same, don't conflate them. Thank you for stressing that point, but I don't think that I conflate them. Maybe I wrong, but I believe that many entries in "io" package share decriptions that states "A successful call ret

[go-nuts] [security] Go 1.17.2 and Go 1.16.9 are released

2021-10-07 Thread Michael Knyszek
Hello gophers, We have just released Go versions 1.17.2 and 1.16.9, minor point releases. These minor releases include a security fix according to the new security policy (#44918 ). When invoking functions from WASM modules, built using GOARCH=wasm GOOS=js, passin

[go-nuts] I am looking for a full-time 100% REMOTE Sr. Golang developer.

2021-10-07 Thread victor baldi
The company is in software development. Main office is in Boston, MS. Working remote is no issue!! See attached job description. If interested please email to: victor.ba...@validity.com Thank you! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group

[go-nuts] Re: copy resp.Body to *bytes.Buffer

2021-10-07 Thread 'Ross Light' via golang-nuts
Use io.Copy . Example: https://play.golang.org/p/89KkmplfZ4M -Ross On Thursday, October 7, 2021 at 5:13:17 AM UTC-7 RS wrote: > How can I copy resp.Body to a *bytes.Buffer? > > I am new to go. > resp.Body is the response which I get from client.Do, and is of type

[go-nuts] xml to json, parsing xml

2021-10-07 Thread RS
What is the best approach to convert xml to json? However I need above all to parse a very complex xml to see if related properties are existing. I thought maybe converting it to Json maybe make it easier. -- You received this message because you are subscribed to the Google Groups "golang-

Re: [go-nuts] Re: Questions about documentation of Go standard library

2021-10-07 Thread Michael Ellis
Kamil, Have you read https://go.dev/blog/errors-are-values by Rob Pike? Wrapping my head around the concept that an error is simply a value returned from a function was tremendously helpful when I had questions along the same lines as yours. -- You received this message because you are subscr

[go-nuts] copy resp.Body to *bytes.Buffer

2021-10-07 Thread RS
How can I copy resp.Body to a *bytes.Buffer? I am new to go. resp.Body is the response which I get from client.Do, and is of type *http.Response -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

Re: [go-nuts] sending server response to a client by w responseWriter

2021-10-07 Thread 'Axel Wagner' via golang-nuts
On Thu, Oct 7, 2021 at 1:43 PM RiSi wrote: > if error happens by io.Copy, can I set the status Code of w after io.Copy? > No. io.Copy might have already written parts of the body. You can't set the status after parts of the body have been written. > > > Am Do., 7. Okt. 2021 um 13:41 Uhr schri

Re: [go-nuts] sending server response to a client by w responseWriter

2021-10-07 Thread RiSi
if error happens by io.Copy, can I set the status Code of w after io.Copy? Am Do., 7. Okt. 2021 um 13:41 Uhr schrieb RiSi : > > *w.Header().Set("Content-Type", "application/xml")* > > *_, err:=io.Copy(w,src) * > > *if err!=nil{* > *re := &res{ Message: "Error happened",}* > > > > *w.Header().Set

Re: [go-nuts] sending server response to a client by w responseWriter

2021-10-07 Thread RiSi
*w.Header().Set("Content-Type", "application/xml")* *_, err:=io.Copy(w,src) * *if err!=nil{* *re := &res{ Message: "Error happened",}* *w.Header().Set("Content-Type", "application/json")w.WriteHeader(599) //sample status codeerr = json.NewEncoder(w).Encode(re)* *}//if* *the part after err!=ni

Re: [go-nuts] sending server response to a client by w responseWriter

2021-10-07 Thread 'Axel Wagner' via golang-nuts
As I said in your last thread: https://groups.google.com/g/golang-nuts/c/I5gwXr1kOA0/m/oIVYRgBoAQAJ What you want is impossible, based on how HTTP works. The status of a request must be determined *before* any of the body is written. So, if writing the body fails, there is nothing more you can do -

[go-nuts] sending server response to a client by w responseWriter

2021-10-07 Thread RS
Best practice in following scenario: In my func for an endpoint (handler) with func hello(w http.ResponseWriter, req *http.Request) I call another server get the resp.Body (Body io.ReadCloser) and want to write this Body in w (ResponseWriter ). What is best practice? I have already copied dir

Re: [go-nuts] Re: Questions about documentation of Go standard library

2021-10-07 Thread Kamil Ziemian
> > I'm not sure what you mean when you say that io.EOF is not treated as an > error. io.EOF is an error: it implements the error interface, and is > returned as the error value by methods such as Read. I am mediocre at best at programming and I'm quite a picky person, so I just have a problem w

[go-nuts] Draining http response bodies

2021-10-07 Thread Amnon
Is it necessary for a http client to fully read the http response body? Opinion on the Go forums seems divided https://forum.golangbridge.org/t/do-i-need-to-read-the-body-before-close-it/5594 But a simple benchmark https://play.golang.org/p/5JDWYbRe0lD suggests that leaving unread data in the re

[go-nuts] Better documentation needed on draining http request bodies

2021-10-07 Thread Amnon
Is it necessary to drain a http client to fully read the http response body? Opinion on the Go forums seems divided https://forum.golangbridge.org/t/do-i-need-to-read-the-body-before-close-it/5594 But a simple benchmark https://play.golang.org/p/5JDWYbRe0lD suggests that leaving unread data in