I've been trying to produce the an RSS feed using the System.ServiceModel.Syndication library..
At the moment it's displaying AEST with +1000 (e.g. Thu, 23 Apr 2015 09:44:29 +1000) but i need it to be produced as GMT (e.g. Sat, 07 Dec 2013 19:39:04 GMT)
Is there a way to set or force the date format for PublishDate property in the SyndicationItem? or defaulted to the server time setting ?
The accepted answer on this page says we should check HTTP server responses for both \r\n\r\n and \n\n as the sequence that separates the headers from the content.
Like:
HTTP/1.1 200 Ok\r\n
Server: AAA\r\n
Cache-Control: no-cache\r\n
Date: Fri, 07 Nov 2014 23:20:27 GMT\r\n
Content-Type: text/html\r\n
Connection: close\r\n\r\n <--------------
or:
HTTP/1.1 200 Ok\r\n
Server: AAA\r\n
Cache-Control: no-cache\r\n
Date: Fri, 07 Nov 2014 23:20:27 GMT\r\n
Content-Type: text/html\r\n
Connection: close\n\n <--------------
In all the responses I've seen in Wireshark, servers use \r\n\r\n.
Is it really necessary to check for both? Which servers/protocol versions would use \n\n?
I started off with \r\n\r\n but soon found some sites that used \n\n. And looking at some professional libraries like curl, they also handle \n\n even if it's not according to the standard.
I don't really know the curl code, but see for example here: https://github.com/curl/curl/blob/7a33c4dff985313f60f39fcde2f89d5aa43381c8/lib/http.c#L1406-L1413
/* find the end of the header line */
end = strchr(start, '\r'); /* lines end with CRLF */
if(!end) {
/* in case there's a non-standard compliant line here */
end = strchr(start, '\n');
if(!end)
/* hm, there's no line ending here, use the zero byte! */
end = strchr(start, '\0');
}
Looking at that I think even \0\0 would be handled.
So:
To handle "anything" out there, then yes.
If you want to strictly follow the standard then no.
HTTP spec says:
The line terminator for message-header fields is the sequence CRLF. However, we recommend that applications, when parsing such headers, recognize a single LF as a line terminator and ignore the leading CR.
In practice I've never seen web server with CR line separator.
Using heritrix, I have crawled a site which contained some PDF files. The crawl log shows that the content type for the pdf link is "application/pdf", whereas the response in .warc file (crawl output) shows that the content type is "application/http" as well as "application/pdf" (see the example below:).
WARC/1.0^M
WARC-Type: response^M
WARC-Target-URI: `http://example.com/b/c/files/abc.pdf`^M
WARC-Date: 2014-05-29T10:48:03Z^M
WARC-Payload-Digest: sha1:JMRPMGSNIPHBPSBNPD2VJ2NIOGD75UUK^M
WARC-IP-Address: 86.36.67.50^M
WARC-Record-ID: <urn:uuid:00c8b80f-2851-42a1-a449-3cd9e238bfe9>^M
**Content-Type: application/http; msgtype=response^M**
Content-Length: 592173^M
WARC-Block-Digest: sha256:0a56d251257dbcbd6a54e19a528a56aae3e0c9e92a6702f4048e3b69bb3e0920^M
^M
HTTP/1.1 200 OK^M
Date: Thu, 29 May 2014 10:48:04 GMT^M
Server: Apache/2.4.4 (Unix) OpenSSL/0.9.7d PHP/5.3.12 mod_jk/1.2.35^M
Last-Modified: Wed, 20 Nov 2013 08:13:50 GMT^M
ETag: "90805-4eb975c6bcb80"^M
Accept-Ranges: bytes^M
Content-Length: 591877^M
Connection: close^M
**Content-Type: application/pdf^M**
followed by the content of the PDF file
I do not understand how this is happening. Can anyone please explain?
The WARC file contains:
First the WARC-Header-Metadata, from the beginning to the first empty line. This header describes what follows, ie. a full http response, with header and content. Hence the content-type to application/http.
Then comes the HTTP-Response-Metadata. This header is the actual HTTP header and describes what follows, ie. a PDF document.
I want to send a single mail to multiple recipients from R. I am able to achieve this using sendmail function but when recipients recieve the email, they see only their email address in to field. Looks like sendmail internally loops and sends individual emails to each recipient which is not a true carbon copy. It is important that each recipient sees all the recipients intended for their specific email (business requirement, because they need to reply to all recipients of this email). how can I achieve this using R?
my code
require(sendmailR)
to <- c("vasudeva.naik#abc.com")
header <- list(cc=c("alok.jadhav#abc.com"))
x <- sendmail("toto#abc.com", to, "test", "testing", header=header,control=list(smtpServer=server,verbose=TRUE))
<< 220 equity.xyz.com ESMTP Sendmail 8.11.7p1+Sun/8.11.7; Thu, 11 Jul 2013 21:31:43 -0400 (EDT)
>> HELO HKD03836654
<< 250 equity.xyz.com Hello HKD03836654.gbl.ad.net [169.34.175.142], pleased to meet you
>> MAIL FROM: toto#abc.com
<< 250 2.1.0 toto#abc.com... Sender ok
>> RCPT TO: vasudeva.naik#abc.com
<< 250 2.1.5 vasudeva.naik#abc.com... Recipient ok
>> DATA
<< 354 Enter mail, end with "." on a line by itself
>> <message data>
<< 250 2.0.0 r6C1Vh101169 Message accepted for delivery
>> QUIT
<< 221 2.0.0 equity.csfb.com closing connection
Output from debug option. header information is not present in the debug output.
> sendmail("toto#abc.com", to, "test", "testing", header=header,control=list(smtpServer=server,transport="debug"))
From: toto#abc.com
To: vasudeva.naik#abc.com
Subject: test
Date: Mon, 15 Jul 2013 02:15:29 -0000
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="1a556aa6576e231876dabb67e5a4f58730d3a228654e14705503b6985a6a6707"
This is a message with multiple parts in MIME format.
--1a556aa6576e231876dabb67e5a4f58730d3a228654e14705503b6985a6a6707
Content-Type: text/plain; format=flowed
testing
--1a556aa6576e231876dabb67e5a4f58730d3a228654e14705503b6985a6a6707--
Thanks.
The problem is caused by the usage of parameter header instead of headers. However, it is not that stupid typo as one might think. As we know, we can abbreviate parameter names when calling functions:
myfun <- function(xx = 1) print(xx)
myfun(x = 2)
# [1] 2
It is also possible when having ...:
myfun <- function(xx = 1, ...) print(xx)
myfun(x = 2)
[1] 2
But in this case we have a different and uncommon order of parameters:
sendmail(from, to, subject, msg, ..., headers = list(), control = list())
which not surprisingly cause such problems:
myfun <- function(..., yy = 1) print(yy)
myfun(y = 2)
[1] 1
You need to combine all the real recipients and send the email to each one of the them separately. CC is just informational as such; leave it out and you get BCC So, for example:
to <- c("vasudeva.naik#abc.com") # addresses for the "To" header
cc <- c("alok.jadhav#abc.com") # addresses for the "CC" header
bcc <- c("...") # more addresses, but these won't be visible anywhere
recipients <- c(to, cc, bcc) # need to send the email to everyone (FIXME: drop duplicates)
header <- list(cc=cc) # let everyone know who else gets the mail
x <- sendmail("toto#abc.com", recipients, "test", "testing", header=header, control=list(smtpServer=server,verbose=TRUE))
If you want all addresses in the To header you could use header <- list(to=to) instead.
Note though, above is untested. Should work in theory, but sendmailR might have other plans wrt handling some of the arguments.
To elaborate on my earlier comment. There are two parts to sending email, SMTP that's the protocol for delivering the message to the recipients, and the message content itself.
SMTP that handles the delivery looks something like:
MAIL FROM: toto#abc.com
RCPT TO: vasudeva.naik#abc.com
DATA
<message content here, see below>
.
Note that the FROM and TO here match the arguments to the sendmail() function. That determines who receives the mail.
Now, the message content (well, just the headers) looks something like this:
From: no-reply#example.com
To: everyone#example.com
CC: everyone-else#example.com
And yes the From and To are completely different from the previous ones. This is what the recipients get and see, but it bears no relevance to who actually gets the email. That's why spam in your inbox appears as something you've sent to someone else, even though you're the actual recipient.
Try:
> for (to in recipients) {
+ sendmail(from, to, subject, msg, control...
A couple of possibilities (untested):
Put the list of recipients as the first line in your message body. Rather clunky, but it works. I've actually seen this done with a Bcc: field (which defeats the point of Bcc:, but never mind that).
Instead of a vector of mail recipients, have your to argument be a single string containing all the recipients, separated by commas.
I have faced this problem before, would love to know a more direct solution, but the way I solved it was to create a distribution list and send a single mail to the distribution list. That way everyone sees and can reply all to the list. Hope this solves your problem.
Under /usr/share/lib/zoneinfo
I can see the following 4 different types of info for GMT
GMT
GMT+0
GMT-0
GMT0
Are there any differences between these 4 types of GMT zone times? If so, what are the differences?
I think they are all the same, or at least have the same values.
Yoo can see all here: TimeZones
On my system (and likely yours as well), GMT, GMT+0 and GMT0 are all symlinked to GMT-0. So there is no difference.
Adding to #Hasturkun's answer - on systems based on glibc, GTM, GMT+0 etc will be always symlinked, because that's how it's defined in glibc/timezone/backward mapping file. Specifically:
Link Etc/GMT GMT+0
Link Etc/GMT GMT-0
Link Etc/GMT GMT0
Link Etc/GMT Greenwich