G-WAN,CGI脚本的输出头

I'm trying to set an HTTP header like Content-Type over a CGI script.

In PHP:

header('Content-Type: text/plain');
// or
echo 'Content-Type: text/plain', "

"; // as first line

or in Go:

fmt.Print("Content-Type: text/plain

") // as first line

Both have no effect on the output.

How can this be done?

EDIT

I also tried the following in Go, using the CGI package:

package main

import "fmt"
import "os"
import "net/http/cgi"

func main() {
    r,e := cgi.Request()
    if e != nil {
        fmt.Println(e)
        os.Exit(200)
    }
    fmt.Printf("%#v", r)
    os.Exit(200)
}

but I get the error:

cgi: failed to parse REQUEST_URI into a URL:
查看全部
douwaif22244
douwaif22244
2013/01/16 11:56
  • cgi
  • http
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复