Pig - Chararray data type and Int data types are converted to Chararray implicitly by Pig when REGEX_EXTRACT_ALL - arrays

I have a sample web log data which has IP, date in dd/mmm/yyyy format, url and other details that are generated in a web log. I am trying to separate the web log into fields - IP, date and url. Below are the scripts that I have created in PIG:
A = Load 'weblogs_rebuild sample.txt' using TextLoader() as Log:chararray;
B = foreach A generate flatten (REGEX_EXTRACT_ALL(Log, '([\\S]+)[\\s+-]+[\\[]+([\\d]+)[/]+([\\w]+)[/]+([\\d]+)(.*)[\\]]+[\\s+]+[\\"]+([\\w\\s+/\\d.]+)[\\"]+[\\s+]+(.*)')) as (field1:chararray,date:int,month:chararray,year:int,timefield:chararray,useraction:chararray,userfiled:chararray);
when I press enter after creating relation B, it gives me warning
org.apache.pig.newplan.BaseOperatorPlan - Encountered Warning
NO_LOAD_FUNCTION_FOR_CASTING_BYTEARRAY 14 time(s)
If I press run the relation B script again and press enter, the warning message shows
org.apache.pig.newplan.BaseOperatorPlan - Encountered Warning
NO_LOAD_FUNCTION_FOR_CASTING_BYTEARRAY 21 time(s)
When I do describe B, it shows me all fields in bytearray.
B: {field1: bytearray,date: bytearray,month: bytearray,year: bytearray,timefield: bytearray,useraction: bytearray,userfiled: bytearray}
I am not getting why the numbers are getting multplied by 7 each times and why the datatypes chararray, int have converted to Bytearray.
This is what I see when I do dump B;
(364.635.03.677,26,Oct,2011,:22:39:30 -0500,GET /feeds/press HTTP/1.1,200 0 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)")
Sample web log:
323.81.303.680 - - [25/Oct/2011:01:41:00 -0500] "GET /download/download6.zip HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.19) Gecko/2010031422 Firefox/3.0.19"
668.667.44.3 - - [25/Oct/2011:07:38:30 -0500] "GET /download/download3.zip HTTP/1.1" 200 0 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070719 CentOS/1.5.0.12-3.el5.centos Firefox/1.5.0.12"
13.386.648.380 - - [25/Oct/2011:17:06:00 -0500] "GET /download/download6.zip HTTP/1.1" 200 0 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.3; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.2)"
06.670.03.40 - - [26/Oct/2011:13:24:00 -0500] "GET /product/demos/product2 HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"
18.656.618.46 - - [26/Oct/2011:17:15:30 -0500] "GET /download/download4.zip HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7"
14.688.663.667 - - [26/Oct/2011:21:02:30 -0500] "GET /news HTTP/1.1" 200 0 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; http://help.yahoo.com/help/us/ysearch/slurp)"
13.07.338.684 - - [26/Oct/2011:21:02:30 -0500] "GET /download HTTP/1.1" 200 0 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; OfficeLiveConnector.1.4; OfficeLivePatch.1.3)"
14.688.663.667 - - [26/Oct/2011:21:02:30 -0500] "GET /news HTTP/1.1" 200 0 "/news" "Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; http://help.yahoo.com/help/us/ysearch/slurp)"

Related

Spam from multiple user agents, same IP

I have a lot of spam posts in a forum that I moderate that I can't quite figure out.
(1) The spammer seems to be getting through Captcha
(2) I have logged the same IP (a Charter/Spectrum address -- so I can't block the ASN) for the following User Agents:
[
{
"userAgent": "Nokia7250/1.0 (3.14) Profile/MIDP-1.0 Configuration/CLDC-1.0"
},
{
"userAgent": "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/7.2.1.0 Safari/536.2+"
},
{
"userAgent": "P3P Validator"
},
{
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:40.0) Gecko/20100101 Firefox/40.0"
},
{
"userAgent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
},
{
"userAgent": "Bloglines/3.1 (http://www.bloglines.com)"
},
{
"userAgent": "SonyEricssonK810i/R1KG Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
},
{
"userAgent": "SonyEricssonT610/R201 Profile/MIDP-1.0 Configuration/CLDC-1.0"
},
{
"userAgent": "Mozilla/5.0 (Linux; U; Android 1.5; de-de; Galaxy Build/CUPCAKE) AppleWebKit/528.5 (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1"
},
{
"userAgent": "Baiduspider ( http://www.baidu.com/search/spider.htm)"
},
{
"userAgent": "Mozilla/5.0 (Windows NT 6.2; ARM; Trident/7.0; Touch; rv:11.0; WPDesktop; NOKIA; Lumia 920) like Geckoo"
},
{
"userAgent": "Mozilla/5.0 (Linux; U; Android 1.5; de-de; Galaxy Build/CUPCAKE) AppleWebKit/528.5 (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1"
},
{
"userAgent": "SEC-SGHX210/1.0 UP.Link/6.3.1.13.0"
},
{
"userAgent": "SEC-SGHX210/1.0 UP.Link/6.3.1.13.0"
},
{
"userAgent": "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.14 (KHTML, like Gecko) Chrome/9.0.601.0 Safari/534.14"
},
{
"userAgent": "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"
},
{
"userAgent": "Gaisbot/3.0 (robot#gais.cs.ccu.edu.tw; http://gais.cs.ccu.edu.tw/robot.php)"
},
{
"userAgent": "Mozilla/5.0 (Maemo; Linux armv7l; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 Fennec/10.0.1"
},
{
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:47.0) Gecko/20100101 Firefox/47.0"
},
{
"userAgent": "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3 like Mac OS X; de-de) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8F190"
}
]
]
This is just an example, but the pattern is common. Multiple UA's from the same IP over a period of time, and the IP is almost always tied to a common consumer ISP. Any thoughts on this?
Let me know if you can think of something else I could log that would also be useful. Thanks!
But then why wouldn't the spammer just use something super common like the current Safari iPhone UA?
Spammers usually use specific tools like Xrumer, which allows automatic change useragent, email registration, solve Captcha etc.
Anti-spam efficiency is based on resource consumption. A moderator must waste a few seconds to remove spam, but a spammer must waste a few minutes to made his durty things.
Therefore, it is necessary to deprive the spammer of the opportunity to automate his process.
Use a serious captcha - reCaptcha, hCaptcha, etc.
Close the ability to post without registration.
Prohibit the use of automatic mail services such as mailforspam.com for registration.
If we are dealing with a bot and not a person, invisible fields are added to the registration form, which the person will not fill, but the bot will see these in the HTML code and fill in.
Replacing the Submit button with the corresponding image. <input type = 'submit' value='Post'> remains in the HTML code, but the form is not submitted by it. Submitting the form is done by clicking on the picture, which the robot does not see, but the person sees.
There are many tricks, but it all depends on the capabilities of the forum engine.
To begin with, it would be nice to determine whether a person is spamming or a robot.

python flask + Server Sent Events(SSE) in Google App Engine(GAE)

Hi I am trying to do SSE(Server-Sent Events) with python flask quite similar to this question
I am using SSE to plot a real-time graph in the web app.
My codes are working fine when applied in local, but when I deploy it in GAE(Google App Engine), the data does not seem to be returned(yield)
I found that I should make the response header as following
X-Accel-Buffering: no
in this guide here
So, I tried this code on "main.py"
# render "plot.html" and plot the real-time graph
# plot.html gets the value from /chart-data event stream, and update the graph
#app.route('/plot_graph', methods=["GET", "POST"])
def plot_graph():
return render_template('plot.html')
#app.route('/chart-data')
def chart_data():
def generate_random_data():
while True:
# generating random data
json_data = json.dumps(
{'time': datetime.now().strftime('%Y-%m-%d %H:%M:%S'), 'value': random() * 100})
yield f"data:{json_data}\n\n"
time.sleep(0.5)
resp = Response(generate_random_data(), mimetype='text/event-stream')
resp.headers["X-Accel-Buffering"] = "no"
return resp
Also, in "plot.html" file, it is getting values from /chart-data like this
const source = new EventSource("/chart-data");
source.onmessage = function (event) {
const data = JSON.parse(event.data);
...
}
and this also works well when executed in local machine, but not working on GAE..
for the logs and error messages, when I tried the code on local machine,
and went to the root dir, /plot_graph, /chart-data, the log looks like
127.0.0.1 - - [03/Jul/2020 14:14:19] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [03/Jul/2020 14:14:20] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [03/Jul/2020 14:14:23] "GET /plot_graph HTTP/1.1" 200 -
127.0.0.1 - - [03/Jul/2020 14:14:24] "GET /chart-data HTTP/1.1" 200 -
127.0.0.1 - - [03/Jul/2020 14:15:04] "GET /chart-data HTTP/1.1" 200 -
when I went into /plot_graph, I see a GET request from /chart-data and it works fine(/plot_graph shows a real-time graph). Also, when I go into /chart-data, I can see yielded values being displayed on the web.
In the GAE logs,
2020-07-03 05:22:23 default[20200703t141524] "GET / HTTP/1.1" 200
2020-07-03 05:22:23 default[20200703t141524] "GET /favicon.ico HTTP/1.1" 404
2020-07-03 05:22:38 default[20200703t141524] "GET /plot_graph HTTP/1.1" 200
for the GAE, even if I entered /plot_graph, the GET request does not seemed to be happening. and since it is not getting any values, the graph is not plotted(only the frame for the graph is displayed).
Also, I tried to go into /chart-data of GAE web server, but I could not enter and cannot see any GET request in the logs as I saw on the server on local machine.
Please can you help me with this problem?

symfony 3.4 - vuejs, logged user data under vuejs unavailable

Like in the title. I have a problem with recieving logged user data under vuejs.
I use
- FOS User - to login
- Fos Rest - to api
- Jms Serializer
This is my function to take data from database
public function getUser()
{
$userId = $this->container->get('security.token_storage')->getToken()->getUser('id');
return $this->repository->FindOneBy(['id' => $userId]);
}
Now, when it is in form like above, console.log return an empty object, in vuejs. However, when I change $userId to 5 for example -
$this->repository->FindOneBy(['id' => 5]);
object is available with data.
now. I checked api addres in both cases - works. i also return a dump in both cases. everything in both cases is identical.
this is my log
when $userId
127.0.0.1 - - [07/Apr/2018:03:55:24 +0200] "GET /ekopanel2/web/app_dev.php/api/v1/greenker/user HTTP/1.1" 204 380 "http://localhost:8080/greenker" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0"
and this is when 5
127.0.0.1 - - [07/Apr/2018:03:55:34 +0200] "GET /ekopanel2/web/app_dev.php/api/v1/greenker/user HTTP/1.1" 200 895 "http://localhost:8080/greenker" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0"
i noticed that status code is different, when 5 it is 200 and working, when $userId, status code is 204, so it looks like it gets empty data.
Can you help please?
Let's suppose you are logged in.
If not, $this->container->get('security.token_storage')->getToken()->getUser() would return the string "anon."
Have you tried with this :
$userId = $this->container->get('security.token_storage')->getToken()->getUser()->getId();
Be carefull to check if the user is logged in. Otherwise, it will throw an exception like "Call to a member function getId() on string".

With Angularjs, $http post return response error in Microsoft Edge

Well, while I develop an admin page for test,
a weird problem occurred in Microsoft Edge.
Here's part of source code to fetch response from server of loginCtrl.js
$http({
method: 'POST',
url: Define.apiUrl + 'admin/login',
data: {
user_id: $scope.login_email,
password: $scope.login_password
}
})
.then(function (response) {
if (response.data.success) {
$cookieStore.put(Define.userInfo, response.data.info);
$cookieStore.put(Define.userToken, response.data.token);
}
}, function (data) {
console.log('errors!');
console.log(data);
});
This works well in Chrome and IE
But in Microsoft Edge, This returns error like below
data = null
status = -1
statusText = ""
and below are each status of related files.
# loginCtrl.js
## Chrome response status
Accept-Ranges:bytes
Cache-Control:public, max-age=0
Connection:keep-alive
Content-Length:1877
Content-Type:application/javascript
Date:Fri, 18 Aug 2017 04:06:49 GMT
ETag:W/"755-15df385a23e"
Last-Modified:Fri, 18 Aug 2017 04:06:47 GMT
## Chrome request status
Accept:'*/*'
Accept-Encoding:gzip, deflate, br
Accept-Language:ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Host:localhost:9000
If-Modified-Since:Fri, 18 Aug 2017 02:51:00 GMT
If-None-Match:W/"6f5-15df340413d"
Referer:http://localhost:9000/
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/60.0.3112.101 Safari/537.36
## Edge response status
Accept-Ranges: bytes
Cache-Control: public, max-age=0
Connection: keep-alive
Content-Length: 1807
Content-Type: application/javascript
Date: Fri, 18 Aug 2017 02:06:14 GMT
ETag: W/"70f-15df3173adf"
Last-Modified: Fri, 18 Aug 2017 02:06:12 GMT
## Edge request status
Accept: application/javascript, '*/*'; q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: ko-KR
Connection: Keep-Alive
Host: localhost:9000
Referer: http://localhost:9000/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063
I wonder why only Edge cannot get right responses.
I tried to make headers like 'Content-Type', 'Cache-Control' or add config like cache : false.
But these couldn't fix this problem.
Did I miss something??
Plz any handsome or pretty programmer save me
I've tried to find solution of this, and finally I got one.
Some answers suggested adding tags like
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="Mon, 26 Jul 1997 05:00:00 GMT" />
or adding code into config like
$httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
// extra
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
but these couldn't solve this.
Finally I saw one answer said this may occurred by a kind of policy handling caches in Edge.
This may occur when I use local server to send requests or get responses.
And it will gonna disappear when test on other server not on local.
Actually, I'm still using local server, so I don't know whether this work or not.

iCloud calendar: Getting unauthorized error from CalDav server

I'm trying to PUT an event on iCloud calendar using CalDav. After several proper requests and responses and getting the user principal and calendars, when i try to PUT an event, the server returns Unauthorized error.
Here's the network log from fiddler:
Request:
OPTIONS https://p49-caldav.icloud.com/ HTTP/1.1
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
Host: p49-caldav.icloud.com
Content-Length: 0
Connection: Keep-Alive
Response:
HTTP/1.1 200 OK
Server: AppleHttpServer/1.9.12/0643601
Date: Sat, 16 Jul 2016 15:38:55 GMT
Content-Type: text/plain; charset=UTF-8
Content-Length: 0
Connection: keep-alive
X-Apple-Jingle-Correlation-Key: X27XPFLXYFCYHGGADAAWWCKMJE
apple-seq: 0
apple-tk: false
X-Responding-Instance: caldavj:44900101:pv42p49ic-zteg05101201:8501:16D67:82b3920
Allow: ACL, COPY, DELETE, GET, HEAD, LOCK, MKCOL, MOVE, OPTIONS, PROPFIND, PROPPATCH, PUT, REPORT, UNLOCK
DAV: 1, access-control, calendar-access, calendar-schedule, calendar-auto-schedule, calendar-managed-attachments, calendarserver-sharing, calendarserver-subscribed, calendarserver-home-sync
X-Accept-Client-Encoding: gzip
Strict-Transport-Security: max-age=31536000; includeSubDomains
via: icloudedge:br30p01ic-ztde01120601:7401:16D44:Berlin
X-Apple-Request-UUID: bebf7795-77c1-4583-98c0-18016b094c49
X-Apple-Xrail: false
access-control-expose-headers: X-Apple-Request-UUID
access-control-expose-headers: Via
Request:
PROPFIND https://p49-caldav.icloud.com/ HTTP/1.1
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
Depth: 0
Host: p49-caldav.icloud.com
Content-Type: text/xml
Content-Length: 89
<propfind xmlns="DAV:">
<prop>
<current-user-principal />
</prop>
</propfind>
Response:
HTTP/1.1 207 Multi-Status
Server: AppleHttpServer/1.9.12/0643601
Date: Sat, 16 Jul 2016 15:38:55 GMT
Content-Type: text/xml
Content-Length: 350
Connection: keep-alive
ETag: "B40001-1B000-578A54FB"
Last-Modified: Sat, 16 Jul 2016 15:38:35 GMT
DAV: 1, access-control, calendar-access, calendar-schedule, calendar-auto-schedule, calendar-managed-attachments, calendarserver-sharing, calendarserver-subscribed, calendarserver-home-sync
Accept-Ranges: bytes
X-Responding-Server: pv42p49ic-zteg04102301 21 a63660a6f7d1a25b5a7ed66dab0da843
X-Transaction-Id: b8d02729-1bcd-4df1-a1ce-3c2a545ed3f0
Vary: accept-encoding
Strict-Transport-Security: max-age=31536000; includeSubDomains
via: icloudedge:br30p01ic-ztde01120601:7401:16D44:Berlin
X-Apple-Request-UUID: b8d02729-1bcd-4df1-a1ce-3c2a545ed3f0
X-Apple-Xrail: false
access-control-expose-headers: X-Apple-Request-UUID
access-control-expose-headers: Via
<?xml version='1.0' encoding='UTF-8'?>
<multistatus xmlns='DAV:'>
<response>
<href>/</href>
<propstat>
<prop>
<current-user-principal>
<href>/10430699202/principal/</href>
</current-user-principal>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
Request:
PROPFIND https://p49-caldav.icloud.com/10430699202/principal/ HTTP/1.1
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
Depth: 0
Host: p49-caldav.icloud.com
Content-Type: text/xml
Content-Length: 122
<propfind xmlns="DAV:">
<prop>
<calendar-home-set xmlns="urn:ietf:params:xml:ns:caldav" />
</prop>
</propfind>
Response:
HTTP/1.1 207 Multi-Status
Server: AppleHttpServer/1.9.12/0643601
Date: Sat, 16 Jul 2016 15:38:56 GMT
Content-Type: text/xml
Content-Length: 446
Connection: keep-alive
DAV: 1, access-control, calendar-access, calendar-schedule, calendar-auto-schedule, calendar-managed-attachments, calendarserver-sharing, calendarserver-subscribed, calendarserver-home-sync
Accept-Ranges: bytes
X-Responding-Server: pv42p49ic-zteg04102001 22 a63660a6f7d1a25b5a7ed66dab0da843
X-Transaction-Id: 9b4aa58d-69d9-4e82-bd90-48380b1650cc
Vary: accept-encoding
Strict-Transport-Security: max-age=31536000; includeSubDomains
via: icloudedge:br30p01ic-ztde01120601:7401:16D44:Berlin
X-Apple-Request-UUID: 9b4aa58d-69d9-4e82-bd90-48380b1650cc
X-Apple-Xrail: false
access-control-expose-headers: X-Apple-Request-UUID
access-control-expose-headers: Via
<?xml version='1.0' encoding='UTF-8'?>
<multistatus xmlns='DAV:'>
<response>
<href>/10430699202/principal/</href>
<propstat>
<prop>
<calendar-home-set xmlns='urn:ietf:params:xml:ns:caldav'>
<href xmlns='DAV:'>https://p49-caldav.icloud.com:443/10430699202/calendars/</href>
</calendar-home-set>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
Request:
PUT https://p49-caldav.icloud.com/10430699202/calendars/ee451a47-c242-40c1-b295-4f1251a5d0cd.ics HTTP/1.1
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
Host: p49-caldav.icloud.com
If-None-Match: *
Content-Type: text/calendar
Content-Length: 302
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//tracky/iCal//FUBU v1.0//EN
BEGIN:VEVENT
UID:ee451a47-c242-40c1-b295-4f1251a5d0cd
DESCRIPTION:
DTEND:20160716T202635
DTSTAMP:20160716T155652Z
DTSTART:20160716T202635
LAST-MODIFIED:20160716T155652Z
SEQUENCE:1468684613
SUMMARY:
END:VEVENT
END:VCALENDAR
Response:
HTTP/1.1 301 Moved Permanently
Server: AppleHttpServer/1.9.12/0643601
Date: Sat, 16 Jul 2016 15:56:53 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 216
Connection: keep-alive
Location: https://p49-caldav.icloud.com/10430699202/calendars/ee451a47-c242-40c1-b295-4f1251a5d0cd.ics/
X-Responding-Server: pv42p49ic-zteg04092901 6 a63660a6f7d1a25b5a7ed66dab0da843
X-Transaction-Id: e537a470-ddf6-4a8f-a059-580d52075840
Strict-Transport-Security: max-age=31536000; includeSubDomains
via: icloudedge:br30p01ic-ztde01130201:7401:16D44:Berlin
X-Apple-Request-UUID: e537a470-ddf6-4a8f-a059-580d52075840
X-Apple-Xrail: false
access-control-expose-headers: X-Apple-Request-UUID
access-control-expose-headers: Via
<html><head><title>Moved Permanently</title></head><body><h1>Moved Permanently</h1><p>Document moved to https://p49-caldav.icloud.com/10430699202/calendars/ee451a47-c242-40c1-b295-4f1251a5d0cd.ics/.</p></body></html>
The server redirects me and removes the authorization header causing the unauthorized error:
PUT https://p49-caldav.icloud.com/10430699202/calendars/ee451a47-c242-40c1-b295-4f1251a5d0cd.ics/ HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
If-None-Match: *
Content-Type: text/calendar
Host: p49-caldav.icloud.com
Content-Length: 302
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//tracky/iCal//FUBU v1.0//EN
BEGIN:VEVENT
UID:ee451a47-c242-40c1-b295-4f1251a5d0cd
DESCRIPTION:
DTEND:20160716T202635
DTSTAMP:20160716T155652Z
DTSTART:20160716T202635
LAST-MODIFIED:20160716T155652Z
SEQUENCE:1468684613
SUMMARY:
END:VEVENT
END:VCALENDAR
Response:
HTTP/1.1 401 Unauthorized
Server: AppleHttpServer/1.9.12/0643601
Date: Sat, 16 Jul 2016 15:56:53 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 141
Connection: keep-alive
WWW-Authenticate: x-mobileme-authtoken realm="MMCalDav"
WWW-Authenticate: basic realm="MMCalDav"
X-Responding-Server: pv42p49ic-zteg05101701 1 a63660a6f7d1a25b5a7ed66dab0da843
X-Transaction-Id: 25cf8cf5-3c86-4c11-915f-f51ee9c79c86
Strict-Transport-Security: max-age=31536000; includeSubDomains
via: icloudedge:br30p01ic-ztde01130201:7401:16D44:Berlin
X-Apple-Request-UUID: 25cf8cf5-3c86-4c11-915f-f51ee9c79c86
X-Apple-Xrail: false
access-control-expose-headers: X-Apple-Request-UUID
access-control-expose-headers: Via
<html><head><title>Unauthorized</title></head><body><h1>Unauthorized</h1><p>You are not authorized to access this resource.</p></body></html>
When I targeted the redirecting URL encountered another error:
<html><head><title>Conflict</title></head><body><h1>Conflict</h1><p>cannot PUT to non-existent parent</p></body></html>
What am I doing wrong?
You are trying to PUT an event into the calendar homeset collection:
PUT https://p49-caldav.icloud.com
/10430699202 # user scope
/calendars # calendar home
/??? # calendar
/ee451a47-c242-40c1-b295-4f1251a5d0cd.ics # event
A calendar homeset contains calendars, not events. So the next step is selecting the calendar you want to put your event into (e.g. the default calendar).
You can list the available calendars (and todo lists) with another PROPFIND Depth:1 on the homeset.

Resources