From 72ec31bc0bcfe458c1f37965be72f062db549156 Mon Sep 17 00:00:00 2001 From: Fabian Weber <> Date: Fri, 6 Mar 2020 10:25:31 +0100 Subject: [PATCH] Moved IPP Content Type to const file --- constants.go | 2 ++ ipp-client.go | 12 ++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/constants.go b/constants.go index 8bab34e..72bdafa 100644 --- a/constants.go +++ b/constants.go @@ -295,6 +295,8 @@ const ( MimeTypePostscript = "application/postscript" MimeTypeOctetStream = "application/octet-stream" + + ContentTypeIPP = "application/ipp" ) const ( diff --git a/ipp-client.go b/ipp-client.go index c2e01ef..97de4ff 100644 --- a/ipp-client.go +++ b/ipp-client.go @@ -14,10 +14,6 @@ import ( "strconv" ) -const ( - ippContentType = "application/ipp" -) - type Document struct { Document io.Reader Size int @@ -101,7 +97,7 @@ func (c *IPPClient) SendRequest(url string, req *Request, additionalResponseData } httpReq.Header.Set("Content-Length", strconv.Itoa(size)) - httpReq.Header.Set("Content-Type", ippContentType) + httpReq.Header.Set("Content-Type", ContentTypeIPP) if c.username != "" && c.password != "" { httpReq.SetBasicAuth(c.username, c.password) @@ -117,12 +113,12 @@ func (c *IPPClient) SendRequest(url string, req *Request, additionalResponseData return nil, fmt.Errorf("ipp server returned with http status code %d", httpResp.StatusCode) } - //read the response into a temp buffer due to some wired EOF errors + // read the response into a temp buffer due to some wired EOF errors httpBody, _ := ioutil.ReadAll(httpResp.Body) - //fmt.Println(httpBody) + // fmt.Println(httpBody) return NewResponseDecoder(bytes.NewBuffer(httpBody)).Decode(additionalResponseData) - //return NewResponseDecoder(httpResp.Body).Decode() + // return NewResponseDecoder(httpResp.Body).Decode() } // Print one or more `Document`s using IPP `Create-Job` followed by `Send-Document` request(s).