Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5cf345273 | ||
|
|
c68ce57488 | ||
|
|
2b161650fe | ||
|
|
dbbef1fb6d | ||
|
|
90518a01a8 | ||
|
|
056e55abbb |
32
LICENSE
32
LICENSE
@@ -1,5 +1,3 @@
|
||||
go-gemini is available under the terms of the MIT license:
|
||||
|
||||
Copyright (c) 2020 Adnan Maolood
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -19,33 +17,3 @@ go-gemini is available under the terms of the MIT license:
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
Portions of this program were taken from Go:
|
||||
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
27
LICENSE-GO
Normal file
27
LICENSE-GO
Normal file
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
15
README.md
15
README.md
@@ -2,9 +2,9 @@
|
||||
|
||||
[](https://godocs.io/git.sr.ht/~adnano/go-gemini) [](https://builds.sr.ht/~adnano/go-gemini?)
|
||||
|
||||
Package gemini implements the [Gemini protocol](https://gemini.circumlunar.space) in Go.
|
||||
|
||||
It provides an API similar to that of net/http to make it easy to develop Gemini clients and servers.
|
||||
Package gemini implements the [Gemini protocol](https://gemini.circumlunar.space)
|
||||
in Go. It provides an API similar to that of net/http to facilitate the
|
||||
development of Gemini clients and servers.
|
||||
|
||||
Compatible with version v0.14.3 of the Gemini specification.
|
||||
|
||||
@@ -12,6 +12,9 @@ Compatible with version v0.14.3 of the Gemini specification.
|
||||
|
||||
import "git.sr.ht/~adnano/go-gemini"
|
||||
|
||||
Note that some filesystem-related functionality is only available on Go 1.16
|
||||
or later as it relies on the io/fs package.
|
||||
|
||||
## Examples
|
||||
|
||||
There are a few examples provided in the examples directory.
|
||||
@@ -24,3 +27,9 @@ To run an example:
|
||||
Send patches and questions to [~adnano/go-gemini-devel](https://lists.sr.ht/~adnano/go-gemini-devel).
|
||||
|
||||
Subscribe to release announcements on [~adnano/go-gemini-announce](https://lists.sr.ht/~adnano/go-gemini-announce).
|
||||
|
||||
## License
|
||||
|
||||
go-gemini is licensed under the terms of the MIT license (see LICENSE).
|
||||
Portions of this library were adapted from Go and are governed by a BSD-style
|
||||
license (see LICENSE-GO). Those files are marked accordingly.
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,5 +1,5 @@
|
||||
module git.sr.ht/~adnano/go-gemini
|
||||
|
||||
go 1.16
|
||||
go 1.15
|
||||
|
||||
require golang.org/x/net v0.0.0-20210119194325-5f4716e94777
|
||||
|
||||
4
mux.go
4
mux.go
@@ -1,3 +1,7 @@
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE-GO file.
|
||||
|
||||
package gemini
|
||||
|
||||
import (
|
||||
|
||||
@@ -80,7 +80,7 @@ func ReadResponse(r io.ReadCloser) (*Response, error) {
|
||||
if !ok {
|
||||
return nil, ErrInvalidResponse
|
||||
}
|
||||
if len(meta) == 0 || len(meta) > 1024 {
|
||||
if len(meta) == 0 {
|
||||
return nil, ErrInvalidResponse
|
||||
}
|
||||
resp.Meta = string(meta)
|
||||
|
||||
@@ -2,6 +2,7 @@ package gemini
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -91,7 +92,7 @@ func TestReadWriteResponse(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Logf("%#v", test.Raw)
|
||||
resp, err := ReadResponse(io.NopCloser(strings.NewReader(test.Raw)))
|
||||
resp, err := ReadResponse(ioutil.NopCloser(strings.NewReader(test.Raw)))
|
||||
if err != test.Err {
|
||||
t.Errorf("expected err = %v, got %v", test.Err, err)
|
||||
}
|
||||
@@ -105,7 +106,7 @@ func TestReadWriteResponse(t *testing.T) {
|
||||
if resp.Meta != test.Meta {
|
||||
t.Errorf("expected meta = %s, got %s", test.Meta, resp.Meta)
|
||||
}
|
||||
b, _ := io.ReadAll(resp.Body)
|
||||
b, _ := ioutil.ReadAll(resp.Body)
|
||||
body := string(b)
|
||||
if body != test.Body {
|
||||
t.Errorf("expected body = %#v, got %#v", test.Body, body)
|
||||
|
||||
Reference in New Issue
Block a user