func (this *Downloader) Stop() { this.Status = DOWNLOADER_STATUS_STOP clientList := make([]*http.Client, 0) client := http.NewClient() clientList = append(clientList, client) this.ClientList = clientList }
// make cookie jar if not exist func (this *Downloader) makeClientIfNotExist(cookieJar int) { clientLength := len(this.ClientList) if (clientLength - 1) >= cookieJar { return } cookieMutex.Lock() fixEnd := cookieJar + 1 log.Println("none cookie jar", cookieJar, "so make up to it") for i := clientLength; i < fixEnd; i++ { jar, _ := cookiejar.New(nil) client := http.NewClient() client.GoClient.Jar = jar this.ClientList = append(this.ClientList, client) } cookieMutex.Unlock() }
func NewDownloader(resuqstQuene *RequestQuene, responseQuene *ResponseQuene, downloadInterval int) *Downloader { clientList := make([]*http.Client, 0) client := http.NewClient() clientList = append(clientList, client) return &Downloader{DOWNLOADER_STATUS_STOPED, resuqstQuene, responseQuene, clientList, downloadInterval} }