fixup header filling after making new request
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
		
							
								
								
									
										23
									
								
								http.go
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								http.go
									
									
									
									
									
								
							| @@ -123,23 +123,11 @@ func newRequest(addr string, req client.Request, ct string, cf codec.Codec, msg | ||||
| } | ||||
|  | ||||
| func (h *httpClient) call(ctx context.Context, addr string, req client.Request, rsp interface{}, opts client.CallOptions) error { | ||||
| 	header := make(http.Header, 2) | ||||
| 	if md, ok := metadata.FromOutgoingContext(ctx); ok { | ||||
| 		for k, v := range md { | ||||
| 			header.Set(k, v) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	ct := req.ContentType() | ||||
| 	if len(opts.ContentType) > 0 { | ||||
| 		ct = opts.ContentType | ||||
| 	} | ||||
|  | ||||
| 	// set timeout in nanoseconds | ||||
| 	header.Set("Timeout", fmt.Sprintf("%d", opts.RequestTimeout)) | ||||
| 	// set the content type for the request | ||||
| 	header.Set("Content-Type", ct) | ||||
|  | ||||
| 	cf, err := h.newCodec(ct) | ||||
| 	if err != nil { | ||||
| 		return errors.InternalServerError("go.micro.client", err.Error()) | ||||
| @@ -149,7 +137,16 @@ func (h *httpClient) call(ctx context.Context, addr string, req client.Request, | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	hreq.Header = header | ||||
| 	if md, ok := metadata.FromOutgoingContext(ctx); ok { | ||||
| 		for k, v := range md { | ||||
| 			hreq.Header.Set(k, v) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// set timeout in nanoseconds | ||||
| 	hreq.Header.Set("Timeout", fmt.Sprintf("%d", opts.RequestTimeout)) | ||||
| 	// set the content type for the request | ||||
| 	hreq.Header.Set("Content-Type", ct) | ||||
|  | ||||
| 	// make the request | ||||
| 	hrsp, err := h.httpcli.Do(hreq.WithContext(ctx)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user