Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5cf345273 | ||
|
|
c68ce57488 | ||
|
|
2b161650fe | ||
|
|
dbbef1fb6d | ||
|
|
90518a01a8 | ||
|
|
056e55abbb |
64
LICENSE
64
LICENSE
@@ -1,51 +1,19 @@
|
|||||||
go-gemini is available under the terms of the MIT license:
|
Copyright (c) 2020 Adnan Maolood
|
||||||
|
|
||||||
Copyright (c) 2020 Adnan Maolood
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
The above copyright notice and this permission notice shall be included in all
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
copies or substantial portions of the Software.
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
copies or substantial portions of the Software.
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
SOFTWARE.
|
||||||
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?)
|
[](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.
|
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
|
||||||
It provides an API similar to that of net/http to make it easy to develop Gemini clients and servers.
|
development of Gemini clients and servers.
|
||||||
|
|
||||||
Compatible with version v0.14.3 of the Gemini specification.
|
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"
|
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
|
## Examples
|
||||||
|
|
||||||
There are a few examples provided in the examples directory.
|
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).
|
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).
|
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
|
module git.sr.ht/~adnano/go-gemini
|
||||||
|
|
||||||
go 1.16
|
go 1.15
|
||||||
|
|
||||||
require golang.org/x/net v0.0.0-20210119194325-5f4716e94777
|
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
|
package gemini
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func ReadResponse(r io.ReadCloser) (*Response, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrInvalidResponse
|
return nil, ErrInvalidResponse
|
||||||
}
|
}
|
||||||
if len(meta) == 0 || len(meta) > 1024 {
|
if len(meta) == 0 {
|
||||||
return nil, ErrInvalidResponse
|
return nil, ErrInvalidResponse
|
||||||
}
|
}
|
||||||
resp.Meta = string(meta)
|
resp.Meta = string(meta)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package gemini
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -91,7 +92,7 @@ func TestReadWriteResponse(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Logf("%#v", test.Raw)
|
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 {
|
if err != test.Err {
|
||||||
t.Errorf("expected err = %v, got %v", test.Err, 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 {
|
if resp.Meta != test.Meta {
|
||||||
t.Errorf("expected meta = %s, got %s", test.Meta, resp.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)
|
body := string(b)
|
||||||
if body != test.Body {
|
if body != test.Body {
|
||||||
t.Errorf("expected body = %#v, got %#v", test.Body, body)
|
t.Errorf("expected body = %#v, got %#v", test.Body, body)
|
||||||
|
|||||||
Reference in New Issue
Block a user