// Copyright 2024 Matthew Rich . All rights reserved. package transport import ( _ "errors" "io" _ "os" "net/url" "net/http" "context" "path/filepath" ) type HTTPWriter struct { *HTTP post *HTTPConnection } func NewHTTPWriter(u *url.URL, ctx context.Context) (h *HTTPWriter, err error) { h = &HTTPWriter { HTTP: &HTTP { ctx: ctx, uri: u, path: filepath.Join(u.Hostname(), u.RequestURI()), }, post: NewHTTPConnection(http.DefaultClient), } h.extension() h.DetectGzip() err = h.post.NewPostRequest(h.ctx, h.uri.String()) return } /* func (h *HTTP) Signature() (documentSignature string) { if h.get.Response() != nil { documentSignature = h.get.Response().Header.Get("Signature") if documentSignature == "" { signatureResp, signatureErr := h.Client.Get(fmt.Sprintf("%s.sig", h.uri.String())) if signatureErr == nil { defer signatureResp.Body.Close() readSignatureBody, readSignatureErr := io.ReadAll(signatureResp.Body) if readSignatureErr == nil { documentSignature = string(readSignatureBody) } } } } return documentSignature } func (h *HTTP) ContentType() (contenttype string) { contenttype = h.get.Response().Header.Get("Content-Type") switch contenttype { case "application/octet-stream": return h.exttype default: } return } */ func (h *HTTPWriter) Writer() io.WriteCloser { return h.post } func (h *HTTPWriter) PostRequest() *http.Request { return h.post.Request() } func (h *HTTPWriter) PostResponse() *http.Response { return h.post.Response() }