summaryrefslogtreecommitdiff
path: root/gopher/response.go
diff options
context:
space:
mode:
Diffstat (limited to 'gopher/response.go')
-rw-r--r--gopher/response.go70
1 files changed, 35 insertions, 35 deletions
diff --git a/gopher/response.go b/gopher/response.go
index 566623f..527e742 100644
--- a/gopher/response.go
+++ b/gopher/response.go
@@ -6,49 +6,49 @@ import (
"io"
"sync"
- sr "tildegit.org/tjp/sliderule"
+ "tildegit.org/tjp/sliderule/internal/types"
)
// The Canonical gopher item types.
const (
- TextFileType sr.Status = '0'
- MenuType sr.Status = '1'
- CSOPhoneBookType sr.Status = '2'
- ErrorType sr.Status = '3'
- MacBinHexType sr.Status = '4'
- DosBinType sr.Status = '5'
- UuencodedType sr.Status = '6'
- SearchType sr.Status = '7'
- TelnetSessionType sr.Status = '8'
- BinaryFileType sr.Status = '9'
- MirrorServerType sr.Status = '+'
- GifFileType sr.Status = 'g'
- ImageFileType sr.Status = 'I'
- Telnet3270Type sr.Status = 'T'
+ TextFileType types.Status = '0'
+ MenuType types.Status = '1'
+ CSOPhoneBookType types.Status = '2'
+ ErrorType types.Status = '3'
+ MacBinHexType types.Status = '4'
+ DosBinType types.Status = '5'
+ UuencodedType types.Status = '6'
+ SearchType types.Status = '7'
+ TelnetSessionType types.Status = '8'
+ BinaryFileType types.Status = '9'
+ MirrorServerType types.Status = '+'
+ GifFileType types.Status = 'g'
+ ImageFileType types.Status = 'I'
+ Telnet3270Type types.Status = 'T'
)
// The gopher+ types.
const (
- BitmapType sr.Status = ':'
- MovieFileType sr.Status = ';'
- SoundFileType sr.Status = '<'
+ BitmapType types.Status = ':'
+ MovieFileType types.Status = ';'
+ SoundFileType types.Status = '<'
)
// The various non-canonical gopher types.
const (
- DocumentType sr.Status = 'd'
- HTMLType sr.Status = 'h'
- InfoMessageType sr.Status = 'i'
- PngImageFileType sr.Status = 'p'
- RtfDocumentType sr.Status = 'r'
- WavSoundFileType sr.Status = 's'
- PdfDocumentType sr.Status = 'P'
- XmlDocumentType sr.Status = 'X'
+ DocumentType types.Status = 'd'
+ HTMLType types.Status = 'h'
+ InfoMessageType types.Status = 'i'
+ PngImageFileType types.Status = 'p'
+ RtfDocumentType types.Status = 'r'
+ WavSoundFileType types.Status = 's'
+ PdfDocumentType types.Status = 'P'
+ XmlDocumentType types.Status = 'X'
)
// MapItem is a single item in a gophermap.
type MapItem struct {
- Type sr.Status
+ Type types.Status
Display string
Selector string
Hostname string
@@ -70,8 +70,8 @@ func (mi MapItem) String() string {
// Response builds a response which contains just this single MapItem.
//
// Meta in the response will be a pointer to the MapItem.
-func (mi *MapItem) Response() *sr.Response {
- return &sr.Response{
+func (mi *MapItem) Response() *types.Response {
+ return &types.Response{
Status: mi.Type,
Meta: &mi,
Body: bytes.NewBufferString(mi.String() + ".\r\n"),
@@ -89,8 +89,8 @@ func (md MapDocument) String() string {
// Response builds a gopher response containing the gophermap.
//
// Meta will be the MapDocument itself.
-func (md MapDocument) Response() *sr.Response {
- return &sr.Response{
+func (md MapDocument) Response() *types.Response {
+ return &types.Response{
Status: DocumentType,
Meta: md,
Body: md.serialize(),
@@ -119,12 +119,12 @@ func Error(err error) *MapItem {
// File builds a minimal response delivering a file's contents.
//
// Meta is nil and Status is 0 in this response.
-func File(status sr.Status, contents io.Reader) *sr.Response {
- return &sr.Response{Status: status, Body: contents}
+func File(status types.Status, contents io.Reader) *types.Response {
+ return &types.Response{Status: status, Body: contents}
}
// NewResponseReader produces a reader which supports reading gopher protocol responses.
-func NewResponseReader(response *sr.Response) sr.ResponseReader {
+func NewResponseReader(response *types.Response) types.ResponseReader {
return &responseReader{
Response: response,
once: &sync.Once{},
@@ -132,7 +132,7 @@ func NewResponseReader(response *sr.Response) sr.ResponseReader {
}
type responseReader struct {
- *sr.Response
+ *types.Response
reader io.Reader
once *sync.Once
}