Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../proc/self/root/lib64/python3....
File: poplib.py
"""A POP3 client class.
[0] Fix | Delete
[1] Fix | Delete
Based on the J. Myers POP3 draft, Jan. 96
[2] Fix | Delete
"""
[3] Fix | Delete
[4] Fix | Delete
# Author: David Ascher <david_ascher@brown.edu>
[5] Fix | Delete
# [heavily stealing from nntplib.py]
[6] Fix | Delete
# Updated: Piers Lauder <piers@cs.su.oz.au> [Jul '97]
[7] Fix | Delete
# String method conversion and test jig improvements by ESR, February 2001.
[8] Fix | Delete
# Added the POP3_SSL class. Methods loosely based on IMAP_SSL. Hector Urtubia <urtubia@mrbook.org> Aug 2003
[9] Fix | Delete
[10] Fix | Delete
# Example (see the test function at the end of this file)
[11] Fix | Delete
[12] Fix | Delete
# Imports
[13] Fix | Delete
[14] Fix | Delete
import errno
[15] Fix | Delete
import re
[16] Fix | Delete
import socket
[17] Fix | Delete
[18] Fix | Delete
try:
[19] Fix | Delete
import ssl
[20] Fix | Delete
HAVE_SSL = True
[21] Fix | Delete
except ImportError:
[22] Fix | Delete
HAVE_SSL = False
[23] Fix | Delete
[24] Fix | Delete
__all__ = ["POP3","error_proto"]
[25] Fix | Delete
[26] Fix | Delete
# Exception raised when an error or invalid response is received:
[27] Fix | Delete
[28] Fix | Delete
class error_proto(Exception): pass
[29] Fix | Delete
[30] Fix | Delete
# Standard Port
[31] Fix | Delete
POP3_PORT = 110
[32] Fix | Delete
[33] Fix | Delete
# POP SSL PORT
[34] Fix | Delete
POP3_SSL_PORT = 995
[35] Fix | Delete
[36] Fix | Delete
# Line terminators (we always output CRLF, but accept any of CRLF, LFCR, LF)
[37] Fix | Delete
CR = b'\r'
[38] Fix | Delete
LF = b'\n'
[39] Fix | Delete
CRLF = CR+LF
[40] Fix | Delete
[41] Fix | Delete
# maximal line length when calling readline(). This is to prevent
[42] Fix | Delete
# reading arbitrary length lines. RFC 1939 limits POP3 line length to
[43] Fix | Delete
# 512 characters, including CRLF. We have selected 2048 just to be on
[44] Fix | Delete
# the safe side.
[45] Fix | Delete
_MAXLINE = 2048
[46] Fix | Delete
[47] Fix | Delete
[48] Fix | Delete
class POP3:
[49] Fix | Delete
[50] Fix | Delete
"""This class supports both the minimal and optional command sets.
[51] Fix | Delete
Arguments can be strings or integers (where appropriate)
[52] Fix | Delete
(e.g.: retr(1) and retr('1') both work equally well.
[53] Fix | Delete
[54] Fix | Delete
Minimal Command Set:
[55] Fix | Delete
USER name user(name)
[56] Fix | Delete
PASS string pass_(string)
[57] Fix | Delete
STAT stat()
[58] Fix | Delete
LIST [msg] list(msg = None)
[59] Fix | Delete
RETR msg retr(msg)
[60] Fix | Delete
DELE msg dele(msg)
[61] Fix | Delete
NOOP noop()
[62] Fix | Delete
RSET rset()
[63] Fix | Delete
QUIT quit()
[64] Fix | Delete
[65] Fix | Delete
Optional Commands (some servers support these):
[66] Fix | Delete
RPOP name rpop(name)
[67] Fix | Delete
APOP name digest apop(name, digest)
[68] Fix | Delete
TOP msg n top(msg, n)
[69] Fix | Delete
UIDL [msg] uidl(msg = None)
[70] Fix | Delete
CAPA capa()
[71] Fix | Delete
STLS stls()
[72] Fix | Delete
UTF8 utf8()
[73] Fix | Delete
[74] Fix | Delete
Raises one exception: 'error_proto'.
[75] Fix | Delete
[76] Fix | Delete
Instantiate with:
[77] Fix | Delete
POP3(hostname, port=110)
[78] Fix | Delete
[79] Fix | Delete
NB: the POP protocol locks the mailbox from user
[80] Fix | Delete
authorization until QUIT, so be sure to get in, suck
[81] Fix | Delete
the messages, and quit, each time you access the
[82] Fix | Delete
mailbox.
[83] Fix | Delete
[84] Fix | Delete
POP is a line-based protocol, which means large mail
[85] Fix | Delete
messages consume lots of python cycles reading them
[86] Fix | Delete
line-by-line.
[87] Fix | Delete
[88] Fix | Delete
If it's available on your mail server, use IMAP4
[89] Fix | Delete
instead, it doesn't suffer from the two problems
[90] Fix | Delete
above.
[91] Fix | Delete
"""
[92] Fix | Delete
[93] Fix | Delete
encoding = 'UTF-8'
[94] Fix | Delete
[95] Fix | Delete
def __init__(self, host, port=POP3_PORT,
[96] Fix | Delete
timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
[97] Fix | Delete
self.host = host
[98] Fix | Delete
self.port = port
[99] Fix | Delete
self._tls_established = False
[100] Fix | Delete
self.sock = self._create_socket(timeout)
[101] Fix | Delete
self.file = self.sock.makefile('rb')
[102] Fix | Delete
self._debugging = 0
[103] Fix | Delete
self.welcome = self._getresp()
[104] Fix | Delete
[105] Fix | Delete
def _create_socket(self, timeout):
[106] Fix | Delete
return socket.create_connection((self.host, self.port), timeout)
[107] Fix | Delete
[108] Fix | Delete
def _putline(self, line):
[109] Fix | Delete
if self._debugging > 1: print('*put*', repr(line))
[110] Fix | Delete
self.sock.sendall(line + CRLF)
[111] Fix | Delete
[112] Fix | Delete
[113] Fix | Delete
# Internal: send one command to the server (through _putline())
[114] Fix | Delete
[115] Fix | Delete
def _putcmd(self, line):
[116] Fix | Delete
if self._debugging: print('*cmd*', repr(line))
[117] Fix | Delete
line = bytes(line, self.encoding)
[118] Fix | Delete
self._putline(line)
[119] Fix | Delete
[120] Fix | Delete
[121] Fix | Delete
# Internal: return one line from the server, stripping CRLF.
[122] Fix | Delete
# This is where all the CPU time of this module is consumed.
[123] Fix | Delete
# Raise error_proto('-ERR EOF') if the connection is closed.
[124] Fix | Delete
[125] Fix | Delete
def _getline(self):
[126] Fix | Delete
line = self.file.readline(_MAXLINE + 1)
[127] Fix | Delete
if len(line) > _MAXLINE:
[128] Fix | Delete
raise error_proto('line too long')
[129] Fix | Delete
[130] Fix | Delete
if self._debugging > 1: print('*get*', repr(line))
[131] Fix | Delete
if not line: raise error_proto('-ERR EOF')
[132] Fix | Delete
octets = len(line)
[133] Fix | Delete
# server can send any combination of CR & LF
[134] Fix | Delete
# however, 'readline()' returns lines ending in LF
[135] Fix | Delete
# so only possibilities are ...LF, ...CRLF, CR...LF
[136] Fix | Delete
if line[-2:] == CRLF:
[137] Fix | Delete
return line[:-2], octets
[138] Fix | Delete
if line[:1] == CR:
[139] Fix | Delete
return line[1:-1], octets
[140] Fix | Delete
return line[:-1], octets
[141] Fix | Delete
[142] Fix | Delete
[143] Fix | Delete
# Internal: get a response from the server.
[144] Fix | Delete
# Raise 'error_proto' if the response doesn't start with '+'.
[145] Fix | Delete
[146] Fix | Delete
def _getresp(self):
[147] Fix | Delete
resp, o = self._getline()
[148] Fix | Delete
if self._debugging > 1: print('*resp*', repr(resp))
[149] Fix | Delete
if not resp.startswith(b'+'):
[150] Fix | Delete
raise error_proto(resp)
[151] Fix | Delete
return resp
[152] Fix | Delete
[153] Fix | Delete
[154] Fix | Delete
# Internal: get a response plus following text from the server.
[155] Fix | Delete
[156] Fix | Delete
def _getlongresp(self):
[157] Fix | Delete
resp = self._getresp()
[158] Fix | Delete
list = []; octets = 0
[159] Fix | Delete
line, o = self._getline()
[160] Fix | Delete
while line != b'.':
[161] Fix | Delete
if line.startswith(b'..'):
[162] Fix | Delete
o = o-1
[163] Fix | Delete
line = line[1:]
[164] Fix | Delete
octets = octets + o
[165] Fix | Delete
list.append(line)
[166] Fix | Delete
line, o = self._getline()
[167] Fix | Delete
return resp, list, octets
[168] Fix | Delete
[169] Fix | Delete
[170] Fix | Delete
# Internal: send a command and get the response
[171] Fix | Delete
[172] Fix | Delete
def _shortcmd(self, line):
[173] Fix | Delete
self._putcmd(line)
[174] Fix | Delete
return self._getresp()
[175] Fix | Delete
[176] Fix | Delete
[177] Fix | Delete
# Internal: send a command and get the response plus following text
[178] Fix | Delete
[179] Fix | Delete
def _longcmd(self, line):
[180] Fix | Delete
self._putcmd(line)
[181] Fix | Delete
return self._getlongresp()
[182] Fix | Delete
[183] Fix | Delete
[184] Fix | Delete
# These can be useful:
[185] Fix | Delete
[186] Fix | Delete
def getwelcome(self):
[187] Fix | Delete
return self.welcome
[188] Fix | Delete
[189] Fix | Delete
[190] Fix | Delete
def set_debuglevel(self, level):
[191] Fix | Delete
self._debugging = level
[192] Fix | Delete
[193] Fix | Delete
[194] Fix | Delete
# Here are all the POP commands:
[195] Fix | Delete
[196] Fix | Delete
def user(self, user):
[197] Fix | Delete
"""Send user name, return response
[198] Fix | Delete
[199] Fix | Delete
(should indicate password required).
[200] Fix | Delete
"""
[201] Fix | Delete
return self._shortcmd('USER %s' % user)
[202] Fix | Delete
[203] Fix | Delete
[204] Fix | Delete
def pass_(self, pswd):
[205] Fix | Delete
"""Send password, return response
[206] Fix | Delete
[207] Fix | Delete
(response includes message count, mailbox size).
[208] Fix | Delete
[209] Fix | Delete
NB: mailbox is locked by server from here to 'quit()'
[210] Fix | Delete
"""
[211] Fix | Delete
return self._shortcmd('PASS %s' % pswd)
[212] Fix | Delete
[213] Fix | Delete
[214] Fix | Delete
def stat(self):
[215] Fix | Delete
"""Get mailbox status.
[216] Fix | Delete
[217] Fix | Delete
Result is tuple of 2 ints (message count, mailbox size)
[218] Fix | Delete
"""
[219] Fix | Delete
retval = self._shortcmd('STAT')
[220] Fix | Delete
rets = retval.split()
[221] Fix | Delete
if self._debugging: print('*stat*', repr(rets))
[222] Fix | Delete
numMessages = int(rets[1])
[223] Fix | Delete
sizeMessages = int(rets[2])
[224] Fix | Delete
return (numMessages, sizeMessages)
[225] Fix | Delete
[226] Fix | Delete
[227] Fix | Delete
def list(self, which=None):
[228] Fix | Delete
"""Request listing, return result.
[229] Fix | Delete
[230] Fix | Delete
Result without a message number argument is in form
[231] Fix | Delete
['response', ['mesg_num octets', ...], octets].
[232] Fix | Delete
[233] Fix | Delete
Result when a message number argument is given is a
[234] Fix | Delete
single response: the "scan listing" for that message.
[235] Fix | Delete
"""
[236] Fix | Delete
if which is not None:
[237] Fix | Delete
return self._shortcmd('LIST %s' % which)
[238] Fix | Delete
return self._longcmd('LIST')
[239] Fix | Delete
[240] Fix | Delete
[241] Fix | Delete
def retr(self, which):
[242] Fix | Delete
"""Retrieve whole message number 'which'.
[243] Fix | Delete
[244] Fix | Delete
Result is in form ['response', ['line', ...], octets].
[245] Fix | Delete
"""
[246] Fix | Delete
return self._longcmd('RETR %s' % which)
[247] Fix | Delete
[248] Fix | Delete
[249] Fix | Delete
def dele(self, which):
[250] Fix | Delete
"""Delete message number 'which'.
[251] Fix | Delete
[252] Fix | Delete
Result is 'response'.
[253] Fix | Delete
"""
[254] Fix | Delete
return self._shortcmd('DELE %s' % which)
[255] Fix | Delete
[256] Fix | Delete
[257] Fix | Delete
def noop(self):
[258] Fix | Delete
"""Does nothing.
[259] Fix | Delete
[260] Fix | Delete
One supposes the response indicates the server is alive.
[261] Fix | Delete
"""
[262] Fix | Delete
return self._shortcmd('NOOP')
[263] Fix | Delete
[264] Fix | Delete
[265] Fix | Delete
def rset(self):
[266] Fix | Delete
"""Unmark all messages marked for deletion."""
[267] Fix | Delete
return self._shortcmd('RSET')
[268] Fix | Delete
[269] Fix | Delete
[270] Fix | Delete
def quit(self):
[271] Fix | Delete
"""Signoff: commit changes on server, unlock mailbox, close connection."""
[272] Fix | Delete
resp = self._shortcmd('QUIT')
[273] Fix | Delete
self.close()
[274] Fix | Delete
return resp
[275] Fix | Delete
[276] Fix | Delete
def close(self):
[277] Fix | Delete
"""Close the connection without assuming anything about it."""
[278] Fix | Delete
try:
[279] Fix | Delete
file = self.file
[280] Fix | Delete
self.file = None
[281] Fix | Delete
if file is not None:
[282] Fix | Delete
file.close()
[283] Fix | Delete
finally:
[284] Fix | Delete
sock = self.sock
[285] Fix | Delete
self.sock = None
[286] Fix | Delete
if sock is not None:
[287] Fix | Delete
try:
[288] Fix | Delete
sock.shutdown(socket.SHUT_RDWR)
[289] Fix | Delete
except OSError as exc:
[290] Fix | Delete
# The server might already have closed the connection.
[291] Fix | Delete
# On Windows, this may result in WSAEINVAL (error 10022):
[292] Fix | Delete
# An invalid operation was attempted.
[293] Fix | Delete
if (exc.errno != errno.ENOTCONN
[294] Fix | Delete
and getattr(exc, 'winerror', 0) != 10022):
[295] Fix | Delete
raise
[296] Fix | Delete
finally:
[297] Fix | Delete
sock.close()
[298] Fix | Delete
[299] Fix | Delete
#__del__ = quit
[300] Fix | Delete
[301] Fix | Delete
[302] Fix | Delete
# optional commands:
[303] Fix | Delete
[304] Fix | Delete
def rpop(self, user):
[305] Fix | Delete
"""Not sure what this does."""
[306] Fix | Delete
return self._shortcmd('RPOP %s' % user)
[307] Fix | Delete
[308] Fix | Delete
[309] Fix | Delete
timestamp = re.compile(br'\+OK.[^<]*(<.*>)')
[310] Fix | Delete
[311] Fix | Delete
def apop(self, user, password):
[312] Fix | Delete
"""Authorisation
[313] Fix | Delete
[314] Fix | Delete
- only possible if server has supplied a timestamp in initial greeting.
[315] Fix | Delete
[316] Fix | Delete
Args:
[317] Fix | Delete
user - mailbox user;
[318] Fix | Delete
password - mailbox password.
[319] Fix | Delete
[320] Fix | Delete
NB: mailbox is locked by server from here to 'quit()'
[321] Fix | Delete
"""
[322] Fix | Delete
secret = bytes(password, self.encoding)
[323] Fix | Delete
m = self.timestamp.match(self.welcome)
[324] Fix | Delete
if not m:
[325] Fix | Delete
raise error_proto('-ERR APOP not supported by server')
[326] Fix | Delete
import hashlib
[327] Fix | Delete
digest = m.group(1)+secret
[328] Fix | Delete
digest = hashlib.md5(digest).hexdigest()
[329] Fix | Delete
return self._shortcmd('APOP %s %s' % (user, digest))
[330] Fix | Delete
[331] Fix | Delete
[332] Fix | Delete
def top(self, which, howmuch):
[333] Fix | Delete
"""Retrieve message header of message number 'which'
[334] Fix | Delete
and first 'howmuch' lines of message body.
[335] Fix | Delete
[336] Fix | Delete
Result is in form ['response', ['line', ...], octets].
[337] Fix | Delete
"""
[338] Fix | Delete
return self._longcmd('TOP %s %s' % (which, howmuch))
[339] Fix | Delete
[340] Fix | Delete
[341] Fix | Delete
def uidl(self, which=None):
[342] Fix | Delete
"""Return message digest (unique id) list.
[343] Fix | Delete
[344] Fix | Delete
If 'which', result contains unique id for that message
[345] Fix | Delete
in the form 'response mesgnum uid', otherwise result is
[346] Fix | Delete
the list ['response', ['mesgnum uid', ...], octets]
[347] Fix | Delete
"""
[348] Fix | Delete
if which is not None:
[349] Fix | Delete
return self._shortcmd('UIDL %s' % which)
[350] Fix | Delete
return self._longcmd('UIDL')
[351] Fix | Delete
[352] Fix | Delete
[353] Fix | Delete
def utf8(self):
[354] Fix | Delete
"""Try to enter UTF-8 mode (see RFC 6856). Returns server response.
[355] Fix | Delete
"""
[356] Fix | Delete
return self._shortcmd('UTF8')
[357] Fix | Delete
[358] Fix | Delete
[359] Fix | Delete
def capa(self):
[360] Fix | Delete
"""Return server capabilities (RFC 2449) as a dictionary
[361] Fix | Delete
>>> c=poplib.POP3('localhost')
[362] Fix | Delete
>>> c.capa()
[363] Fix | Delete
{'IMPLEMENTATION': ['Cyrus', 'POP3', 'server', 'v2.2.12'],
[364] Fix | Delete
'TOP': [], 'LOGIN-DELAY': ['0'], 'AUTH-RESP-CODE': [],
[365] Fix | Delete
'EXPIRE': ['NEVER'], 'USER': [], 'STLS': [], 'PIPELINING': [],
[366] Fix | Delete
'UIDL': [], 'RESP-CODES': []}
[367] Fix | Delete
>>>
[368] Fix | Delete
[369] Fix | Delete
Really, according to RFC 2449, the cyrus folks should avoid
[370] Fix | Delete
having the implementation split into multiple arguments...
[371] Fix | Delete
"""
[372] Fix | Delete
def _parsecap(line):
[373] Fix | Delete
lst = line.decode('ascii').split()
[374] Fix | Delete
return lst[0], lst[1:]
[375] Fix | Delete
[376] Fix | Delete
caps = {}
[377] Fix | Delete
try:
[378] Fix | Delete
resp = self._longcmd('CAPA')
[379] Fix | Delete
rawcaps = resp[1]
[380] Fix | Delete
for capline in rawcaps:
[381] Fix | Delete
capnm, capargs = _parsecap(capline)
[382] Fix | Delete
caps[capnm] = capargs
[383] Fix | Delete
except error_proto as _err:
[384] Fix | Delete
raise error_proto('-ERR CAPA not supported by server')
[385] Fix | Delete
return caps
[386] Fix | Delete
[387] Fix | Delete
[388] Fix | Delete
def stls(self, context=None):
[389] Fix | Delete
"""Start a TLS session on the active connection as specified in RFC 2595.
[390] Fix | Delete
[391] Fix | Delete
context - a ssl.SSLContext
[392] Fix | Delete
"""
[393] Fix | Delete
if not HAVE_SSL:
[394] Fix | Delete
raise error_proto('-ERR TLS support missing')
[395] Fix | Delete
if self._tls_established:
[396] Fix | Delete
raise error_proto('-ERR TLS session already established')
[397] Fix | Delete
caps = self.capa()
[398] Fix | Delete
if not 'STLS' in caps:
[399] Fix | Delete
raise error_proto('-ERR STLS not supported by server')
[400] Fix | Delete
if context is None:
[401] Fix | Delete
context = ssl._create_stdlib_context()
[402] Fix | Delete
resp = self._shortcmd('STLS')
[403] Fix | Delete
self.sock = context.wrap_socket(self.sock,
[404] Fix | Delete
server_hostname=self.host)
[405] Fix | Delete
self.file = self.sock.makefile('rb')
[406] Fix | Delete
self._tls_established = True
[407] Fix | Delete
return resp
[408] Fix | Delete
[409] Fix | Delete
[410] Fix | Delete
if HAVE_SSL:
[411] Fix | Delete
[412] Fix | Delete
class POP3_SSL(POP3):
[413] Fix | Delete
"""POP3 client class over SSL connection
[414] Fix | Delete
[415] Fix | Delete
Instantiate with: POP3_SSL(hostname, port=995, keyfile=None, certfile=None,
[416] Fix | Delete
context=None)
[417] Fix | Delete
[418] Fix | Delete
hostname - the hostname of the pop3 over ssl server
[419] Fix | Delete
port - port number
[420] Fix | Delete
keyfile - PEM formatted file that contains your private key
[421] Fix | Delete
certfile - PEM formatted certificate chain file
[422] Fix | Delete
context - a ssl.SSLContext
[423] Fix | Delete
[424] Fix | Delete
See the methods of the parent class POP3 for more documentation.
[425] Fix | Delete
"""
[426] Fix | Delete
[427] Fix | Delete
def __init__(self, host, port=POP3_SSL_PORT, keyfile=None, certfile=None,
[428] Fix | Delete
timeout=socket._GLOBAL_DEFAULT_TIMEOUT, context=None):
[429] Fix | Delete
if context is not None and keyfile is not None:
[430] Fix | Delete
raise ValueError("context and keyfile arguments are mutually "
[431] Fix | Delete
"exclusive")
[432] Fix | Delete
if context is not None and certfile is not None:
[433] Fix | Delete
raise ValueError("context and certfile arguments are mutually "
[434] Fix | Delete
"exclusive")
[435] Fix | Delete
if keyfile is not None or certfile is not None:
[436] Fix | Delete
import warnings
[437] Fix | Delete
warnings.warn("keyfile and certfile are deprecated, use a "
[438] Fix | Delete
"custom context instead", DeprecationWarning, 2)
[439] Fix | Delete
self.keyfile = keyfile
[440] Fix | Delete
self.certfile = certfile
[441] Fix | Delete
if context is None:
[442] Fix | Delete
context = ssl._create_stdlib_context(certfile=certfile,
[443] Fix | Delete
keyfile=keyfile)
[444] Fix | Delete
self.context = context
[445] Fix | Delete
POP3.__init__(self, host, port, timeout)
[446] Fix | Delete
[447] Fix | Delete
def _create_socket(self, timeout):
[448] Fix | Delete
sock = POP3._create_socket(self, timeout)
[449] Fix | Delete
sock = self.context.wrap_socket(sock,
[450] Fix | Delete
server_hostname=self.host)
[451] Fix | Delete
return sock
[452] Fix | Delete
[453] Fix | Delete
def stls(self, keyfile=None, certfile=None, context=None):
[454] Fix | Delete
"""The method unconditionally raises an exception since the
[455] Fix | Delete
STLS command doesn't make any sense on an already established
[456] Fix | Delete
SSL/TLS session.
[457] Fix | Delete
"""
[458] Fix | Delete
raise error_proto('-ERR TLS session already established')
[459] Fix | Delete
[460] Fix | Delete
__all__.append("POP3_SSL")
[461] Fix | Delete
[462] Fix | Delete
if __name__ == "__main__":
[463] Fix | Delete
import sys
[464] Fix | Delete
a = POP3(sys.argv[1])
[465] Fix | Delete
print(a.getwelcome())
[466] Fix | Delete
a.user(sys.argv[2])
[467] Fix | Delete
a.pass_(sys.argv[3])
[468] Fix | Delete
a.list()
[469] Fix | Delete
(numMsgs, totalSize) = a.stat()
[470] Fix | Delete
for i in range(1, numMsgs + 1):
[471] Fix | Delete
(header, msg, octets) = a.retr(i)
[472] Fix | Delete
print("Message %d:" % i)
[473] Fix | Delete
for line in msg:
[474] Fix | Delete
print(' ' + line)
[475] Fix | Delete
print('-----------------------')
[476] Fix | Delete
a.quit()
[477] Fix | Delete
[478] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function